@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 +6 -2
- package/dist/types/apps/session-picker.d.ts +13 -1
- package/dist/types/overlays/resume-picker.d.ts +293 -0
- package/dist/types/overlays/resume-tree.d.ts +353 -0
- package/dist/types/overlays/session-selector.d.ts +22 -4
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/tools/hub.d.ts +3 -1
- package/dist/types/tools/irc.d.ts +5 -1
- package/dist/types/tools/wait.d.ts +6 -0
- package/package.json +9 -9
- package/src/apps/session-picker.ts +20 -2
- package/src/overlays/resume-picker.ts +706 -0
- package/src/overlays/resume-tree.ts +1901 -0
- package/src/overlays/session-selector.ts +579 -39
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +11 -0
- package/src/tools/hub.ts +4 -1
- package/src/tools/irc.d.ts +5 -1
- package/src/tools/irc.ts +5 -1
- package/src/tools/proc-render.ts +1 -0
- package/src/tools/wait.d.ts +6 -0
- package/src/tools/wait.ts +6 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI three-level resume tree: project → workspace → conversation.
|
|
3
|
+
*
|
|
4
|
+
* Renders the rows produced by the coding-agent resume view model; it never
|
|
5
|
+
* groups sessions itself. The model arrives through {@link ResumeTreeSource},
|
|
6
|
+
* which the host builds from `loadResumeDirectory` + `buildResumeView` (pi-tui
|
|
7
|
+
* cannot depend on the coding-agent package). Scope cycling, collapse state,
|
|
8
|
+
* search focus, pin actions and the delete confirmation live here; view
|
|
9
|
+
* construction and persistence live in the host.
|
|
10
|
+
*/
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import { type Component } from "../index.js";
|
|
13
|
+
export type ResumeTreeScope = "workspace" | "project" | "all";
|
|
14
|
+
/** Persisted picker state (v2 file): scope plus local expansion. */
|
|
15
|
+
export interface ResumeTreePickerState {
|
|
16
|
+
scope: ResumeTreeScope;
|
|
17
|
+
collapsedProjects?: readonly string[];
|
|
18
|
+
expandedProjects?: readonly string[];
|
|
19
|
+
collapsedWorkspaces?: readonly string[];
|
|
20
|
+
/** Absolute paths in the project/workspace/cwd labels; absent means false. */
|
|
21
|
+
fullPaths?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type ResumeTreeStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
|
|
24
|
+
export type ResumeTreeDeleteMode = "trash" | "permanent";
|
|
25
|
+
/** The session fields the tree reads from a conversation row. */
|
|
26
|
+
export interface ResumeTreeSession {
|
|
27
|
+
path: string;
|
|
28
|
+
id: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
size?: number;
|
|
31
|
+
title?: string;
|
|
32
|
+
modified: Date;
|
|
33
|
+
firstMessage?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ResumeTreeConversation {
|
|
36
|
+
session: ResumeTreeSession;
|
|
37
|
+
key: string;
|
|
38
|
+
id: string;
|
|
39
|
+
path: string;
|
|
40
|
+
title: string;
|
|
41
|
+
cwd: string;
|
|
42
|
+
projectKey: string;
|
|
43
|
+
workspaceKey: string;
|
|
44
|
+
created: Date;
|
|
45
|
+
modified: Date;
|
|
46
|
+
status?: ResumeTreeStatus;
|
|
47
|
+
pinned: boolean;
|
|
48
|
+
current: boolean;
|
|
49
|
+
fork: boolean;
|
|
50
|
+
/** Subagent marker from `session_init.agent`; forks never set it. */
|
|
51
|
+
isSubagent?: boolean;
|
|
52
|
+
agentName?: string;
|
|
53
|
+
parentKey?: string;
|
|
54
|
+
/** Direct subagent children, when the directory attached them. */
|
|
55
|
+
subagents?: readonly ResumeTreeConversation[];
|
|
56
|
+
messageCount: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ResumeTreeWorkspace {
|
|
59
|
+
key: string;
|
|
60
|
+
path: string;
|
|
61
|
+
name: string;
|
|
62
|
+
/** User-configured alias, or null. The directory name never changes. */
|
|
63
|
+
alias?: string | null;
|
|
64
|
+
/** Alias when set, otherwise `name`. */
|
|
65
|
+
displayName?: string;
|
|
66
|
+
projectKey: string;
|
|
67
|
+
branch: string | null;
|
|
68
|
+
pinned: boolean;
|
|
69
|
+
lastActivity: Date | null;
|
|
70
|
+
counts: {
|
|
71
|
+
conversations: number;
|
|
72
|
+
pinnedConversations: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface ResumeTreeProject {
|
|
76
|
+
key: string;
|
|
77
|
+
root: string;
|
|
78
|
+
name: string;
|
|
79
|
+
alias: string | null;
|
|
80
|
+
displayName: string;
|
|
81
|
+
isDefault: boolean;
|
|
82
|
+
pinned: boolean;
|
|
83
|
+
collapsed: boolean;
|
|
84
|
+
lastActivity: Date | null;
|
|
85
|
+
counts: {
|
|
86
|
+
conversations: number;
|
|
87
|
+
workspaces: number;
|
|
88
|
+
pinnedConversations: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface ResumeTreeProjectRow {
|
|
92
|
+
type: "project";
|
|
93
|
+
key: string;
|
|
94
|
+
project: ResumeTreeProject;
|
|
95
|
+
pinned: boolean;
|
|
96
|
+
collapsed: boolean;
|
|
97
|
+
conversationCount: number;
|
|
98
|
+
totalConversationCount: number;
|
|
99
|
+
workspaceCount: number;
|
|
100
|
+
totalWorkspaceCount: number;
|
|
101
|
+
}
|
|
102
|
+
export interface ResumeTreeWorkspaceRow {
|
|
103
|
+
type: "workspace";
|
|
104
|
+
key: string;
|
|
105
|
+
workspace: ResumeTreeWorkspace;
|
|
106
|
+
projectKey: string;
|
|
107
|
+
pinned: boolean;
|
|
108
|
+
conversationCount: number;
|
|
109
|
+
totalConversationCount: number;
|
|
110
|
+
}
|
|
111
|
+
export interface ResumeTreeConversationRow {
|
|
112
|
+
type: "conversation";
|
|
113
|
+
key: string;
|
|
114
|
+
conversation: ResumeTreeConversation;
|
|
115
|
+
projectKey: string;
|
|
116
|
+
workspaceKey: string;
|
|
117
|
+
pinned: boolean;
|
|
118
|
+
current: boolean;
|
|
119
|
+
pinnedOnly?: boolean;
|
|
120
|
+
}
|
|
121
|
+
export type ResumeTreeRow = ResumeTreeProjectRow | ResumeTreeWorkspaceRow | ResumeTreeConversationRow;
|
|
122
|
+
export interface ResumeTreeView {
|
|
123
|
+
scope: {
|
|
124
|
+
kind: ResumeTreeScope;
|
|
125
|
+
projectKey?: string;
|
|
126
|
+
workspaceKey?: string;
|
|
127
|
+
};
|
|
128
|
+
query: {
|
|
129
|
+
raw: string;
|
|
130
|
+
terms?: readonly string[];
|
|
131
|
+
};
|
|
132
|
+
rows: readonly ResumeTreeRow[];
|
|
133
|
+
conversations?: readonly ResumeTreeConversationRow[];
|
|
134
|
+
counts: {
|
|
135
|
+
conversations: number;
|
|
136
|
+
workspaces?: number;
|
|
137
|
+
projects?: number;
|
|
138
|
+
totalConversations: number;
|
|
139
|
+
totalWorkspaces?: number;
|
|
140
|
+
totalProjects?: number;
|
|
141
|
+
};
|
|
142
|
+
/** Branch of the current session's workspace, when known. */
|
|
143
|
+
referenceBranch?: string | null;
|
|
144
|
+
/** Workspace key of the current session, when known. */
|
|
145
|
+
currentWorkspaceKey?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Names and per-scope conversation totals for the scope header. */
|
|
148
|
+
export interface ResumeTreeScopeSummary {
|
|
149
|
+
workspaceName: string;
|
|
150
|
+
projectName: string;
|
|
151
|
+
counts: Record<ResumeTreeScope, number>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Host bridge. `buildView` must be a pure projection of the loaded directory;
|
|
155
|
+
* `refresh`/`pin*`/`deleteConversation` perform I/O and resolve when the
|
|
156
|
+
* source's internal state is current again.
|
|
157
|
+
*/
|
|
158
|
+
export interface ResumeTreeSource {
|
|
159
|
+
readonly initialScope: ResumeTreeScope;
|
|
160
|
+
buildView(input: {
|
|
161
|
+
scope: ResumeTreeScope;
|
|
162
|
+
query: string;
|
|
163
|
+
currentSessionPath?: string;
|
|
164
|
+
}): ResumeTreeView | null;
|
|
165
|
+
scopeSummary(): ResumeTreeScopeSummary;
|
|
166
|
+
currentSessionPath?(): string | undefined;
|
|
167
|
+
/** Remember the chosen scope across opens. */
|
|
168
|
+
persistScope?(scope: ResumeTreeScope): void | Promise<void>;
|
|
169
|
+
/** Restored v2 picker state (scope + expansion); absent means defaults. */
|
|
170
|
+
pickerState?(): ResumeTreePickerState;
|
|
171
|
+
/** Persist scope + expansion together (preferred over `persistScope`). */
|
|
172
|
+
persistPickerState?(state: ResumeTreePickerState): void | Promise<void>;
|
|
173
|
+
/** Re-read the directory; resolves once `buildView` reflects the new state. */
|
|
174
|
+
refresh?(): Promise<void>;
|
|
175
|
+
/** Partial scan failures (unreadable project folders) while rows are still listed. */
|
|
176
|
+
scanWarningNames?(): readonly string[];
|
|
177
|
+
/** A failed load: no rows available at all. */
|
|
178
|
+
loadError?(): string | undefined;
|
|
179
|
+
isLoading?(): boolean;
|
|
180
|
+
pinConversation?(conversation: ResumeTreeConversation, pinned: boolean): Promise<void>;
|
|
181
|
+
pinProject?(project: ResumeTreeProject, pinned: boolean): Promise<void>;
|
|
182
|
+
pinWorkspace?(workspace: ResumeTreeWorkspace, pinned: boolean): Promise<void>;
|
|
183
|
+
/** Set the workspace display alias; resolves the name the picker now shows. */
|
|
184
|
+
renameWorkspace?(workspace: ResumeTreeWorkspace, alias: string | null): Promise<string | null>;
|
|
185
|
+
openWorkspace?(workspace: ResumeTreeWorkspace): void | Promise<void>;
|
|
186
|
+
/** Rename the persisted session title; resolves the stored name or null. */
|
|
187
|
+
renameConversation?(conversation: ResumeTreeConversation, title: string): Promise<string | null>;
|
|
188
|
+
/** False hides the conversation rename action (read-only/foreign session). */
|
|
189
|
+
canRenameConversation?(conversation: ResumeTreeConversation): boolean;
|
|
190
|
+
/** Scopes without a project header (workspace/project) resolve the project here. */
|
|
191
|
+
projectByKey?(key: string): ResumeTreeProject | undefined;
|
|
192
|
+
deleteConversation?(conversation: ResumeTreeConversation): Promise<boolean>;
|
|
193
|
+
deleteMode: ResumeTreeDeleteMode;
|
|
194
|
+
}
|
|
195
|
+
export interface ResumeTreeOptions {
|
|
196
|
+
source: ResumeTreeSource;
|
|
197
|
+
getTerminalRows?: () => number;
|
|
198
|
+
onSelect: (conversation: ResumeTreeConversation) => void;
|
|
199
|
+
onCancel: () => void;
|
|
200
|
+
onExit: () => void;
|
|
201
|
+
onRequestRender?: () => void;
|
|
202
|
+
/** Start with the search field focused (the default for a resume picker). */
|
|
203
|
+
searchFocused?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** Short relative age, localised through the shared session-picker keys. */
|
|
206
|
+
export declare function formatResumeAge(date: Date, now?: number): string;
|
|
207
|
+
/** Middle-ellipsis truncation for path-like text (`a/b/…/x/y`). */
|
|
208
|
+
export declare function middleEllipsis(text: string, maxWidth: number): string;
|
|
209
|
+
/** Pick the path API from the string's own shape, not the host platform. */
|
|
210
|
+
export declare function resumePathApi(value: string): typeof path.posix;
|
|
211
|
+
/** Full path spelled with its own platform's separators (drive, UNC or POSIX). */
|
|
212
|
+
export declare function absoluteResumePath(value: string): string;
|
|
213
|
+
/** Short parent/name tail or the full absolute path, per the picker toggle. */
|
|
214
|
+
export declare function formatResumePath(value: string, fullPaths: boolean): string;
|
|
215
|
+
/** Basename-first path tail (`parent/name`) keeping the platform separator. */
|
|
216
|
+
export declare function resumePathTail(value: string): string;
|
|
217
|
+
/**
|
|
218
|
+
* Truncate from the left so the tail stays readable, keeping a drive/UNC root
|
|
219
|
+
* when there is room for one (`D:\…\repo`, `\\server\share\…\repo`). The
|
|
220
|
+
* returned string never exceeds `maxWidth` visible columns.
|
|
221
|
+
*/
|
|
222
|
+
export declare function truncateResumePath(value: string, maxWidth: number): string;
|
|
223
|
+
/**
|
|
224
|
+
* A workspace branch is noise when it repeats the current workspace's branch;
|
|
225
|
+
* it is kept for the current workspace or when it actually differs.
|
|
226
|
+
*/
|
|
227
|
+
export declare function shouldShowBranch(branch: string | null | undefined, referenceBranch: string | null | undefined, current: boolean, workspaceName?: string): boolean;
|
|
228
|
+
/** Stable right-hand column widths for the conversation list. */
|
|
229
|
+
export interface ConversationColumns {
|
|
230
|
+
status: number;
|
|
231
|
+
turns: number;
|
|
232
|
+
age: number;
|
|
233
|
+
flags: number;
|
|
234
|
+
}
|
|
235
|
+
/** Width of the status column, fixed across rows so every title starts together. */
|
|
236
|
+
export declare function statusColumnWidth(): number;
|
|
237
|
+
/** Column widths across every visible conversation row, so columns stay put while scrolling. */
|
|
238
|
+
export declare function conversationColumns(rows: readonly ResumeTreeConversationRow[], now?: number): ConversationColumns;
|
|
239
|
+
/**
|
|
240
|
+
* One dense conversation row: `status | title | turns | age | flags | ⋯`.
|
|
241
|
+
* The status cell and every metadata column have fixed widths computed once
|
|
242
|
+
* per frame; the title is the only flexible cell, and nothing ever wraps.
|
|
243
|
+
*/
|
|
244
|
+
export declare function renderConversationRow(row: ResumeTreeConversationRow, options: {
|
|
245
|
+
width: number;
|
|
246
|
+
selected: boolean;
|
|
247
|
+
now?: number;
|
|
248
|
+
columns?: ConversationColumns;
|
|
249
|
+
/** Show the conversation cwd as an absolute path instead of omitting it. */
|
|
250
|
+
fullPaths?: boolean;
|
|
251
|
+
}): string;
|
|
252
|
+
/**
|
|
253
|
+
* One workspace sub-header, indented one visible step: a coloured fold+name,
|
|
254
|
+
* a branch chip when it adds information, and right-aligned counts + `⋯`.
|
|
255
|
+
*/
|
|
256
|
+
export declare function renderWorkspaceRow(row: ResumeTreeWorkspaceRow, options: {
|
|
257
|
+
width: number;
|
|
258
|
+
selected: boolean;
|
|
259
|
+
collapsed: boolean;
|
|
260
|
+
referenceBranch?: string | null;
|
|
261
|
+
current?: boolean;
|
|
262
|
+
/** Show absolute workspace paths instead of parent/name tails. */
|
|
263
|
+
fullPaths?: boolean;
|
|
264
|
+
/** Workspace scope has no use for the path label; callers can omit it. */
|
|
265
|
+
showPath?: boolean;
|
|
266
|
+
}): string;
|
|
267
|
+
/**
|
|
268
|
+
* Project section header: pin + name + path tag on the left, counts/workspaces/
|
|
269
|
+
* age right-aligned. The caller draws a full-width rule under it.
|
|
270
|
+
*/
|
|
271
|
+
export declare function renderProjectRow(row: ResumeTreeProjectRow, options: {
|
|
272
|
+
width: number;
|
|
273
|
+
selected: boolean;
|
|
274
|
+
collapsed: boolean;
|
|
275
|
+
now?: number;
|
|
276
|
+
/** Show the absolute project root instead of the parent/name tail. */
|
|
277
|
+
fullPaths?: boolean;
|
|
278
|
+
}): string;
|
|
279
|
+
/** Full-width rule closing a project section header. */
|
|
280
|
+
export declare function renderProjectRule(width: number): string;
|
|
281
|
+
/** A scope-segment hit range on the header line, in tree-local columns. */
|
|
282
|
+
export interface ResumeScopeHit {
|
|
283
|
+
kind: ResumeTreeScope;
|
|
284
|
+
start: number;
|
|
285
|
+
end: number;
|
|
286
|
+
}
|
|
287
|
+
/** The three-tab scope control with per-scope counts, plus its clickable ranges. */
|
|
288
|
+
export declare function renderScopeHeaderHits(scope: ResumeTreeScope, summary: ResumeTreeScopeSummary, width: number): {
|
|
289
|
+
text: string;
|
|
290
|
+
hits: ResumeScopeHit[];
|
|
291
|
+
};
|
|
292
|
+
/** The three-tab scope control with per-scope counts. */
|
|
293
|
+
export declare function renderScopeHeader(scope: ResumeTreeScope, summary: ResumeTreeScopeSummary, width: number): string;
|
|
294
|
+
interface FlatRow {
|
|
295
|
+
row: ResumeTreeRow;
|
|
296
|
+
/** Visible when every ancestor group is expanded. */
|
|
297
|
+
parentKey?: string;
|
|
298
|
+
}
|
|
299
|
+
export interface ResumeTreeState {
|
|
300
|
+
collapsedProjects: Set<string>;
|
|
301
|
+
expandedProjects: Set<string>;
|
|
302
|
+
collapsedWorkspaces: Set<string>;
|
|
303
|
+
}
|
|
304
|
+
/** Flatten model rows under the current local collapse state (headers always stay). */
|
|
305
|
+
export declare function flattenResumeRows(rows: readonly ResumeTreeRow[], state: ResumeTreeState, searching: boolean): FlatRow[];
|
|
306
|
+
/**
|
|
307
|
+
* The ANSI resume tree component. The host mounts it inside its panel chrome;
|
|
308
|
+
* this component renders the scope control, search field, banners and rows.
|
|
309
|
+
*/
|
|
310
|
+
export declare class ResumeTreeComponent implements Component {
|
|
311
|
+
#private;
|
|
312
|
+
readonly onSelect: (conversation: ResumeTreeConversation) => void;
|
|
313
|
+
readonly onCancel: () => void;
|
|
314
|
+
readonly onExit: () => void;
|
|
315
|
+
onRequestRender?: () => void;
|
|
316
|
+
constructor(options: ResumeTreeOptions);
|
|
317
|
+
/** Rebuild the cached view (call after the host refreshes its directory). */
|
|
318
|
+
invalidate(): void;
|
|
319
|
+
get scope(): ResumeTreeScope;
|
|
320
|
+
get fullPaths(): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Toggle absolute paths. In workspace scope the path is redundant, so the
|
|
323
|
+
* key surfaces a one-line hint and leaves the setting untouched; the
|
|
324
|
+
* project/all scopes actually flip and persist it.
|
|
325
|
+
*/
|
|
326
|
+
toggleFullPaths(): void;
|
|
327
|
+
/** Adopt a host-refreshed view while keeping selection and collapse state. */
|
|
328
|
+
setView(view: ResumeTreeView | null): void;
|
|
329
|
+
/** Cycle workspace → project → all → workspace. */
|
|
330
|
+
cycleScope(direction?: 1 | -1): void;
|
|
331
|
+
/** Switch to a scope (the scope segments and Tab share this path). */
|
|
332
|
+
setScope(scope: ResumeTreeScope): void;
|
|
333
|
+
/** Re-read the directory through the host source. */
|
|
334
|
+
refresh(): Promise<void>;
|
|
335
|
+
/** Focus the search field (the `/` key, and the initial state). */
|
|
336
|
+
focusSearch(): void;
|
|
337
|
+
/** Pin the selected conversation (`p`) or its project (`P`). */
|
|
338
|
+
pinSelected(project: boolean): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Hit-test an SGR mouse report against the rows the last render recorded.
|
|
341
|
+
* The fullscreen picker paints from screen row 0, so callers pass the
|
|
342
|
+
* component's frame offset (`row` of the first rendered line, `col` of its
|
|
343
|
+
* first content column). Keyboard handling never depends on this path.
|
|
344
|
+
*/
|
|
345
|
+
handleMouse(data: string, offset?: {
|
|
346
|
+
row?: number;
|
|
347
|
+
col?: number;
|
|
348
|
+
}): boolean;
|
|
349
|
+
handleInput(keyData: string): void;
|
|
350
|
+
render(width: number): readonly string[];
|
|
351
|
+
dispose(): void;
|
|
352
|
+
}
|
|
353
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Component, Input } from "../index.js";
|
|
2
2
|
import type { TspPickerGroup, TspPickerItem } from "@linxiraos/pi-wire";
|
|
3
3
|
import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node.js";
|
|
4
|
+
import { type ResumeSourceLike } from "./resume-picker.js";
|
|
4
5
|
/** Session lifecycle status presented by the picker. */
|
|
5
6
|
export type SessionSelectorStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
|
|
6
7
|
/** Session listing fields consumed by the picker. */
|
|
@@ -18,6 +19,8 @@ export interface SessionSelectorEntry {
|
|
|
18
19
|
/** Path to the parent session when this one was forked. */
|
|
19
20
|
parentSessionPath?: string;
|
|
20
21
|
}
|
|
22
|
+
import { ResumeTreeComponent } from "./resume-tree.js";
|
|
23
|
+
export type { ResumeConversationLike, ResumeDirectoryLike, ResumeProjectLike, ResumeQueryLike, ResumeScopeInputLike, ResumeScopeKindLike, ResumeSourceLike, ResumeViewLike, ResumeViewRowLike, ResumeWorkspaceLike, } from "./resume-picker.js";
|
|
21
24
|
import { OverlayPanel } from "../chrome/overlay-box.js";
|
|
22
25
|
/** The session list's part of the picker props, plus the memo keys it was built from. */
|
|
23
26
|
interface SessionPickerView {
|
|
@@ -76,6 +79,11 @@ declare class SessionList<T extends SessionSelectorEntry> implements Component {
|
|
|
76
79
|
constructor(sessions: T[], showCwd?: boolean, historyMatcher?: SessionHistoryMatcher, getTerminalRows?: () => number, pinnedIds?: ReadonlySet<string>, currentSessionPath?: string | (() => string | undefined));
|
|
77
80
|
/** Replace the visible dataset, e.g. when toggling folder/all-projects scope. */
|
|
78
81
|
setSessions(sessions: T[], showCwd: boolean, pinnedIds?: ReadonlySet<string>): void;
|
|
82
|
+
/**
|
|
83
|
+
* Resume-model mode: the given sessions are already the model's ordered,
|
|
84
|
+
* filtered view, so mirror them and keep the selection when it survives.
|
|
85
|
+
*/
|
|
86
|
+
syncSessions(sessions: readonly T[], preferredPath?: string | null): void;
|
|
79
87
|
/** Cancel pending async search work; idempotent, called on every picker exit path. */
|
|
80
88
|
dispose(): void;
|
|
81
89
|
removeSession(sessionPath: string): void;
|
|
@@ -125,6 +133,17 @@ export interface SessionSelectorOptions<T extends SessionSelectorEntry = Session
|
|
|
125
133
|
loadAllSessions?: () => Promise<T[]>;
|
|
126
134
|
/** Preloaded all-projects list; cached so the first Tab toggle is instant. */
|
|
127
135
|
allSessions?: T[];
|
|
136
|
+
/**
|
|
137
|
+
* The host's resume model (project → workspace → conversation) and its
|
|
138
|
+
* pure view builder. When set, the native `picker` describes the resume
|
|
139
|
+
* tree instead of the flat day-grouped list; the ANSI path is unchanged.
|
|
140
|
+
*/
|
|
141
|
+
resumeSource?: ResumeSourceLike;
|
|
142
|
+
/**
|
|
143
|
+
* What delete does to the session file: an in-session picker moves it to
|
|
144
|
+
* the trash, `--resume` deletes it permanently. Wording only.
|
|
145
|
+
*/
|
|
146
|
+
deleteMode?: "trash" | "permanent";
|
|
128
147
|
/** Picker heading; defaults to "Resume Session". */
|
|
129
148
|
title?: string;
|
|
130
149
|
/** Primary action label; defaults to "Resume" (ANSI footer defaults to "select"). */
|
|
@@ -160,9 +179,7 @@ export interface SessionSelectorOptions<T extends SessionSelectorEntry = Session
|
|
|
160
179
|
*/
|
|
161
180
|
standalone?: boolean;
|
|
162
181
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Component that renders a session selector with optional confirmation dialog
|
|
165
|
-
*/
|
|
182
|
+
/** Component that renders a session selector with optional confirmation dialog. */
|
|
166
183
|
export declare class SessionSelectorComponent<T extends SessionSelectorEntry = SessionSelectorEntry> extends OverlayPanel {
|
|
167
184
|
#private;
|
|
168
185
|
constructor(sessions: T[], onSelect: (session: T) => void, onCancel: () => void, onExit: () => void, options?: SessionSelectorOptions<T>);
|
|
@@ -196,5 +213,6 @@ export declare class SessionSelectorComponent<T extends SessionSelectorEntry = S
|
|
|
196
213
|
handleNativeEvent(event: NativeUiEvent): void;
|
|
197
214
|
handleInput(keyData: string): void;
|
|
198
215
|
getSessionList(): SessionList<T>;
|
|
216
|
+
/** The ANSI resume tree when the host supplied a resume source. */
|
|
217
|
+
getResumeTree(): ResumeTreeComponent | undefined;
|
|
199
218
|
}
|
|
200
|
-
export {};
|
|
@@ -18,7 +18,7 @@ export declare enum NotifyProtocol {
|
|
|
18
18
|
Osc99 = "\u001B]99;;",
|
|
19
19
|
Osc9 = "\u001B]9;"
|
|
20
20
|
}
|
|
21
|
-
export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "base" | "trueColor";
|
|
21
|
+
export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "zetawork" | "base" | "trueColor";
|
|
22
22
|
/** Terminal capability details used for rendering and protocol selection. */
|
|
23
23
|
export declare class TerminalInfo {
|
|
24
24
|
readonly id: TerminalId;
|
|
@@ -123,6 +123,8 @@ export interface CoordinationDetails {
|
|
|
123
123
|
}[];
|
|
124
124
|
/** Running subagents not represented by a job row in this result. */
|
|
125
125
|
agents?: AgentActivitySnapshot[];
|
|
126
|
+
/** `wait` returned early because blocking would deadlock (mesh S6). */
|
|
127
|
+
status?: "peer-waiting-on-you";
|
|
126
128
|
}
|
|
127
129
|
/** Hub result details: coordination snapshots or launch (process) state. */
|
|
128
130
|
export type HubDetails = CoordinationDetails | LaunchToolDetails;
|
|
@@ -204,7 +206,7 @@ export interface IrcMessage {
|
|
|
204
206
|
/** Delivery outcome for one peer recipient. */
|
|
205
207
|
export interface IrcDeliveryReceipt {
|
|
206
208
|
to: string;
|
|
207
|
-
outcome: "injected" | "woken" | "revived" | "failed";
|
|
209
|
+
outcome: "injected" | "woken" | "revived" | "queued" | "failed";
|
|
208
210
|
error?: string;
|
|
209
211
|
}
|
|
210
212
|
/** Broker-facing launch parameters; the hub adapts its `ps` op to `list` before calling in. */
|
|
@@ -23,7 +23,11 @@ export interface IrcMessage {
|
|
|
23
23
|
/** Delivery outcome for one peer recipient. */
|
|
24
24
|
export interface IrcDeliveryReceipt {
|
|
25
25
|
to: string;
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* `queued` is the cross-process offline path: the message is in the peer's
|
|
28
|
+
* persistent mailbox and will be injected when its process next starts.
|
|
29
|
+
*/
|
|
30
|
+
outcome: "injected" | "woken" | "revived" | "queued" | "failed";
|
|
27
31
|
error?: string;
|
|
28
32
|
}
|
|
29
33
|
/** Status ordering for peer rosters in child prompts. */
|
|
@@ -96,6 +96,12 @@ export interface CoordinationDetails {
|
|
|
96
96
|
agents?: AgentActivitySnapshot[];
|
|
97
97
|
/** `wait` was cut short by steering, a peer message, or a completion notice that injects next. */
|
|
98
98
|
interrupted?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* `wait` returned early without a message because continuing would deadlock:
|
|
101
|
+
* the peer it was waiting on is itself waiting on this agent. Both sides can
|
|
102
|
+
* keep working — answer the peer, then wait again.
|
|
103
|
+
*/
|
|
104
|
+
status?: "peer-waiting-on-you";
|
|
99
105
|
}
|
|
100
106
|
/** Pending wait frame. */
|
|
101
107
|
declare function waitRenderCall(_args: object, _options: RenderResultOptions, uiTheme: Theme): Component;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@linxiraos/pi-tui",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
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/pi-omptype": "1.
|
|
42
|
-
"@linxiraos/pi-agent-core": "1.
|
|
43
|
-
"@linxiraos/pi-ai": "1.
|
|
44
|
-
"@linxiraos/pi-catalog": "1.
|
|
45
|
-
"@linxiraos/pi-natives": "1.
|
|
46
|
-
"@linxiraos/pi-utils": "1.
|
|
47
|
-
"@linxiraos/pi-wire": "1.
|
|
48
|
-
"@linxiraos/pi-snapcompact": "1.
|
|
41
|
+
"@linxiraos/pi-omptype": "1.4.0",
|
|
42
|
+
"@linxiraos/pi-agent-core": "1.4.0",
|
|
43
|
+
"@linxiraos/pi-ai": "1.4.0",
|
|
44
|
+
"@linxiraos/pi-catalog": "1.4.0",
|
|
45
|
+
"@linxiraos/pi-natives": "1.4.0",
|
|
46
|
+
"@linxiraos/pi-utils": "1.4.0",
|
|
47
|
+
"@linxiraos/pi-wire": "1.4.0",
|
|
48
|
+
"@linxiraos/pi-snapcompact": "1.4.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"kitty-vt-wasm": "^0.2.0"
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { logger } from "@linxiraos/pi-utils";
|
|
2
2
|
import {
|
|
3
|
+
type ResumeSourceLike,
|
|
3
4
|
SessionSelectorComponent,
|
|
4
|
-
type SessionSelectorEntry,
|
|
5
5
|
type SessionHistoryMatcher,
|
|
6
|
+
type SessionSelectorEntry,
|
|
7
|
+
type SessionSelectorOptions,
|
|
6
8
|
} from "../overlays/session-selector";
|
|
9
|
+
import type { ResumeTreeSource } from "../overlays/resume-tree";
|
|
7
10
|
import { runStandaloneTui } from "./standalone-picker";
|
|
8
11
|
|
|
9
12
|
/** Persistence and history capabilities supplied by the session-owning host. */
|
|
@@ -12,6 +15,8 @@ export interface SessionPickerHost<T extends SessionSelectorEntry = SessionSelec
|
|
|
12
15
|
loadHistoryMatcher?(): SessionHistoryMatcher;
|
|
13
16
|
deleteSession?(session: T): Promise<boolean>;
|
|
14
17
|
loadAllSessions?(): Promise<T[]>;
|
|
18
|
+
/** Builds the three-level resume source for the standalone `--resume` tree. */
|
|
19
|
+
loadResumeSource?(deleteMode: "trash" | "permanent", workspacePath?: string): Promise<ResumeTreeSource | undefined>;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
/** Presentation and capability controls for the standalone session picker. */
|
|
@@ -24,6 +29,12 @@ export interface SessionPickerOptions<T extends SessionSelectorEntry = SessionSe
|
|
|
24
29
|
allowGlobalScope?: boolean;
|
|
25
30
|
historySearch?: boolean;
|
|
26
31
|
pinnedIds?: ReadonlySet<string>;
|
|
32
|
+
/** Opt into the three-level resume tree; `deleteMode` words the confirm step. */
|
|
33
|
+
resume?: { deleteMode: "trash" | "permanent"; workspacePath?: string };
|
|
34
|
+
/** The host's resume model; when set, the native picker renders the project tree. */
|
|
35
|
+
resumeSource?: ResumeSourceLike;
|
|
36
|
+
/** Delete wording: in-session moves to trash, `--resume` deletes permanently. */
|
|
37
|
+
deleteMode?: "trash" | "permanent";
|
|
27
38
|
}
|
|
28
39
|
|
|
29
40
|
/**
|
|
@@ -51,6 +62,11 @@ export async function selectSession<T extends SessionSelectorEntry>(
|
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
|
|
65
|
+
const resumeMode = options.resume?.deleteMode;
|
|
66
|
+
const resumeSource = resumeMode
|
|
67
|
+
? await host.loadResumeSource?.(resumeMode, options.resume?.workspacePath)
|
|
68
|
+
: undefined;
|
|
69
|
+
|
|
54
70
|
return runStandaloneTui<T | null>(
|
|
55
71
|
({ ui, finish }) => {
|
|
56
72
|
const selector = new SessionSelectorComponent(
|
|
@@ -73,7 +89,9 @@ export async function selectSession<T extends SessionSelectorEntry>(
|
|
|
73
89
|
scopeLabel: options.scopeLabel,
|
|
74
90
|
showCwd: options.showCwd,
|
|
75
91
|
pinnedIds,
|
|
76
|
-
|
|
92
|
+
resumeSource: resumeSource ?? options.resumeSource,
|
|
93
|
+
deleteMode: resumeMode ?? options.deleteMode,
|
|
94
|
+
} as SessionSelectorOptions<T> & { resumeSource?: ResumeTreeSource; deleteMode?: "trash" | "permanent" },
|
|
77
95
|
);
|
|
78
96
|
selector.setOnRequestRender(() => ui.requestRender());
|
|
79
97
|
return selector;
|