@narumitw/pi-btw 0.63.5 → 0.63.6
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 -0
- package/dist/chunks/{main-tree-picker-WHRN26NJ.ts → main-tree-picker-YEHPIYZP.ts} +28 -39
- package/dist/chunks/main-tree-picker-YEHPIYZP.ts.map +7 -0
- package/dist/index.ts +1 -1
- package/package.json +1 -1
- package/src/main-tree-picker.ts +32 -40
- package/dist/chunks/main-tree-picker-WHRN26NJ.ts.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -61,9 +61,7 @@ async function pickMainEntry(pi, ctx, dependencies = {}) {
|
|
|
61
61
|
notifySafely(ctx, "No main-thread entries are available", "warning");
|
|
62
62
|
return { kind: "back" };
|
|
63
63
|
}
|
|
64
|
-
const tree =
|
|
65
|
-
const rawCopyText = collectRawCopyText(rawTree);
|
|
66
|
-
const savedLabels = collectSavedLabels(rawTree);
|
|
64
|
+
const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);
|
|
67
65
|
const createSelector = dependencies.createSelector ?? createNativeTreeSelector;
|
|
68
66
|
const copy = dependencies.copyToClipboard ?? copyText;
|
|
69
67
|
const copyControllers = /* @__PURE__ */ new Set();
|
|
@@ -162,18 +160,35 @@ function createNativeTreeSelector(options) {
|
|
|
162
160
|
result.setViewLabel = (entryId, label, labelTimestamp) => selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);
|
|
163
161
|
return result;
|
|
164
162
|
}
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
function prepareTreeSnapshot(rawTree) {
|
|
164
|
+
const tree = [];
|
|
165
|
+
const rawCopyText = /* @__PURE__ */ new Map();
|
|
166
|
+
const savedLabels = /* @__PURE__ */ new Map();
|
|
167
|
+
const stack = [{ source: rawTree, target: tree, index: 0 }];
|
|
168
|
+
while (stack.length > 0) {
|
|
169
|
+
const frame = stack[stack.length - 1];
|
|
170
|
+
if (frame.index === frame.source.length) {
|
|
171
|
+
stack.pop();
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const node = frame.source[frame.index++];
|
|
175
|
+
const label = node.label === void 0 ? void 0 : sanitizeSingleLine(node.label);
|
|
176
|
+
const labelTimestamp = node.labelTimestamp === void 0 ? void 0 : sanitizeSingleLine(node.labelTimestamp);
|
|
177
|
+
const displayNode = {
|
|
168
178
|
entry: sanitizeEntryForDisplay(node.entry),
|
|
169
|
-
children:
|
|
179
|
+
children: []
|
|
170
180
|
};
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
|
|
181
|
+
if (label !== void 0) displayNode.label = label;
|
|
182
|
+
if (labelTimestamp !== void 0) displayNode.labelTimestamp = labelTimestamp;
|
|
183
|
+
frame.target.push(displayNode);
|
|
184
|
+
const text = getRawCopyText(node.entry);
|
|
185
|
+
if (text !== void 0) rawCopyText.set(node.entry.id, text);
|
|
186
|
+
savedLabels.set(node.entry.id, { label, labelTimestamp });
|
|
187
|
+
if (node.children.length > 0) {
|
|
188
|
+
stack.push({ source: node.children, target: displayNode.children, index: 0 });
|
|
174
189
|
}
|
|
175
|
-
|
|
176
|
-
}
|
|
190
|
+
}
|
|
191
|
+
return { tree, rawCopyText, savedLabels };
|
|
177
192
|
}
|
|
178
193
|
function sanitizeEntryForDisplay(entry) {
|
|
179
194
|
switch (entry.type) {
|
|
@@ -263,18 +278,6 @@ function sanitizeToolArguments(value, seen) {
|
|
|
263
278
|
}
|
|
264
279
|
return result;
|
|
265
280
|
}
|
|
266
|
-
function collectRawCopyText(tree) {
|
|
267
|
-
const result = /* @__PURE__ */ new Map();
|
|
268
|
-
const visit = (nodes) => {
|
|
269
|
-
for (const node of nodes) {
|
|
270
|
-
const text = getRawCopyText(node.entry);
|
|
271
|
-
if (text !== void 0) result.set(node.entry.id, text);
|
|
272
|
-
visit(node.children);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
visit(tree);
|
|
276
|
-
return result;
|
|
277
|
-
}
|
|
278
281
|
function getRawCopyText(entry) {
|
|
279
282
|
let text;
|
|
280
283
|
if (entry.type === "message") {
|
|
@@ -294,20 +297,6 @@ function extractRawText(content) {
|
|
|
294
297
|
(block) => block !== null && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string"
|
|
295
298
|
).map((block) => block.text).join("");
|
|
296
299
|
}
|
|
297
|
-
function collectSavedLabels(tree) {
|
|
298
|
-
const result = /* @__PURE__ */ new Map();
|
|
299
|
-
const visit = (nodes) => {
|
|
300
|
-
for (const node of nodes) {
|
|
301
|
-
result.set(node.entry.id, {
|
|
302
|
-
label: node.label === void 0 ? void 0 : sanitizeSingleLine(node.label),
|
|
303
|
-
labelTimestamp: node.labelTimestamp === void 0 ? void 0 : sanitizeSingleLine(node.labelTimestamp)
|
|
304
|
-
});
|
|
305
|
-
visit(node.children);
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
visit(tree);
|
|
309
|
-
return result;
|
|
310
|
-
}
|
|
311
300
|
async function copyText(text, signal) {
|
|
312
301
|
signal.throwIfAborted();
|
|
313
302
|
await copyToClipboard(text);
|
|
@@ -325,4 +314,4 @@ function formatError(error) {
|
|
|
325
314
|
export {
|
|
326
315
|
pickMainEntry
|
|
327
316
|
};
|
|
328
|
-
//# sourceMappingURL=main-tree-picker-
|
|
317
|
+
//# sourceMappingURL=main-tree-picker-YEHPIYZP.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/main-tree-picker.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n copyToClipboard,\n type ExtensionAPI,\n type ExtensionCommandContext,\n type SessionEntry,\n type SessionTreeNode,\n TreeSelectorComponent,\n} from \"@earendil-works/pi-coding-agent\";\nimport { type Component, type Focusable, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { showBtwCustomPreservingEditor } from \"./menu.js\";\nimport { sanitizeSingleLine } from \"./text.js\";\n\nexport type MainEntryPickResult = { kind: \"selected\"; entryId: string } | { kind: \"back\" } | { kind: \"closed\" };\n\nexport interface MainThreadTreeSelector extends Component, Focusable {\n onCopy?: (text: string | undefined) => void;\n setViewLabel?(entryId: string, label: string | undefined, labelTimestamp?: string): void;\n dispose?(): void;\n}\n\nexport interface MainThreadTreeSelectorOptions {\n tree: SessionTreeNode[];\n currentLeafId: string | null;\n terminalRows: number;\n onSelect: (entryId: string) => void;\n onCancel: () => void;\n onCopy: (entryId: string | undefined, displayText: string | undefined) => void;\n onLabelChange: (entryId: string, label: string | undefined) => void;\n}\n\nexport interface MainThreadTreePickerDependencies {\n createSelector?: (options: MainThreadTreeSelectorOptions) => MainThreadTreeSelector;\n copyToClipboard?: (text: string, signal: AbortSignal) => Promise<void>;\n}\n\nclass MainThreadTreePickerComponent implements Component, Focusable {\n constructor(\n private readonly selector: MainThreadTreeSelector,\n private readonly onClose: () => void,\n ) {}\n\n get focused(): boolean {\n return this.selector.focused;\n }\n\n set focused(value: boolean) {\n this.selector.focused = value;\n }\n\n get wantsKeyRelease(): boolean | undefined {\n return this.selector.wantsKeyRelease;\n }\n\n render(width: number): string[] {\n return this.selector.render(width);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n this.onClose();\n return;\n }\n this.selector.handleInput?.(data);\n }\n\n invalidate(): void {\n this.selector.invalidate();\n }\n\n dispose(): void {\n this.selector.dispose?.();\n this.onClose();\n }\n}\n\nexport async function pickMainEntry(\n pi: ExtensionAPI,\n ctx: ExtensionCommandContext,\n dependencies: MainThreadTreePickerDependencies = {},\n): Promise<MainEntryPickResult> {\n let rawTree: SessionTreeNode[];\n let currentLeafId: string | null;\n try {\n rawTree = ctx.sessionManager.getTree();\n currentLeafId = ctx.sessionManager.getLeafId();\n } catch {\n return { kind: \"closed\" };\n }\n\n if (rawTree.length === 0) {\n notifySafely(ctx, \"No main-thread entries are available\", \"warning\");\n return { kind: \"back\" };\n }\n\n const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);\n const createSelector = dependencies.createSelector ?? createNativeTreeSelector;\n const copy = dependencies.copyToClipboard ?? copyText;\n const copyControllers = new Set<AbortController>();\n const copyTasks = new Set<Promise<void>>();\n const abortCopies = () => {\n for (const controller of copyControllers) {\n controller.abort(new Error(\"The main-thread tree picker closed\"));\n }\n };\n const result = await showBtwCustomPreservingEditor<MainEntryPickResult>(ctx, (tui, _theme, _keybindings, done) => {\n let settled = false;\n let selector: MainThreadTreeSelector | undefined;\n const finish = (value: MainEntryPickResult) => {\n if (settled) return;\n settled = true;\n abortCopies();\n done(value);\n };\n const onCopy = (entryId: string | undefined, displayText: string | undefined) => {\n if (settled) return;\n const text = entryId ? rawCopyText.get(entryId) : displayText;\n if (!text) {\n notifySafely(ctx, \"Selected entry has no text to copy\", \"warning\");\n return;\n }\n const controller = new AbortController();\n copyControllers.add(controller);\n let operation: Promise<void>;\n try {\n operation = copy(text, controller.signal);\n } catch (error: unknown) {\n operation = Promise.reject(error);\n }\n let task!: Promise<void>;\n task = operation\n .then(() => {\n if (!settled) notifySafely(ctx, \"Copied selected message\", \"info\");\n })\n .catch((error: unknown) => {\n if (!settled && !controller.signal.aborted) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n }\n })\n .finally(() => {\n copyControllers.delete(controller);\n copyTasks.delete(task);\n });\n copyTasks.add(task);\n };\n const restoreLabel = (entryId: string) => {\n const previous = savedLabels.get(entryId);\n selector?.setViewLabel?.(entryId, previous?.label, previous?.labelTimestamp);\n tui.requestRender();\n };\n const onLabelChange = (entryId: string, label: string | undefined) => {\n if (settled) return;\n try {\n if (!ctx.sessionManager.getEntry(entryId)) {\n restoreLabel(entryId);\n notifySafely(ctx, \"The selected main-thread entry is no longer available\", \"warning\");\n return;\n }\n const persistedLabel = label === undefined ? undefined : sanitizeSingleLine(label);\n pi.setLabel(entryId, persistedLabel);\n savedLabels.set(entryId, { label: persistedLabel });\n selector?.setViewLabel?.(entryId, persistedLabel);\n tui.requestRender();\n } catch (error: unknown) {\n restoreLabel(entryId);\n notifySafely(ctx, `Could not update tree label: ${formatError(error)}`, \"error\");\n }\n };\n selector = createSelector({\n tree,\n currentLeafId,\n terminalRows: tui.terminal.rows,\n onSelect: (entryId) => finish({ kind: \"selected\", entryId }),\n onCancel: () => finish({ kind: \"back\" }),\n onCopy,\n onLabelChange,\n });\n return new MainThreadTreePickerComponent(selector, () => finish({ kind: \"closed\" }));\n });\n abortCopies();\n await Promise.allSettled([...copyTasks]);\n\n return result ?? { kind: \"closed\" };\n}\n\nfunction createNativeTreeSelector(options: MainThreadTreeSelectorOptions): MainThreadTreeSelector {\n const selector = new TreeSelectorComponent(\n options.tree,\n options.currentLeafId,\n options.terminalRows,\n options.onSelect,\n options.onCancel,\n options.onLabelChange,\n );\n selector.onCopy = (displayText) => options.onCopy(selector.getTreeList().getSelectedNode()?.entry.id, displayText);\n const result = selector as MainThreadTreeSelector;\n result.setViewLabel = (entryId, label, labelTimestamp) =>\n selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);\n return result;\n}\n\nfunction prepareTreeSnapshot(rawTree: readonly SessionTreeNode[]): {\n tree: SessionTreeNode[];\n rawCopyText: Map<string, string>;\n savedLabels: Map<string, SavedLabel>;\n} {\n const tree: SessionTreeNode[] = [];\n const rawCopyText = new Map<string, string>();\n const savedLabels = new Map<string, SavedLabel>();\n // Keep traversal state on the heap: valid session histories can be arbitrarily deep.\n const stack = [{ source: rawTree, target: tree, index: 0 }];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index === frame.source.length) {\n stack.pop();\n continue;\n }\n const node = frame.source[frame.index++];\n const label = node.label === undefined ? undefined : sanitizeSingleLine(node.label);\n const labelTimestamp = node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp);\n const displayNode: SessionTreeNode = {\n entry: sanitizeEntryForDisplay(node.entry),\n children: [],\n };\n if (label !== undefined) displayNode.label = label;\n if (labelTimestamp !== undefined) displayNode.labelTimestamp = labelTimestamp;\n frame.target.push(displayNode);\n const text = getRawCopyText(node.entry);\n if (text !== undefined) rawCopyText.set(node.entry.id, text);\n savedLabels.set(node.entry.id, { label, labelTimestamp });\n if (node.children.length > 0) {\n stack.push({ source: node.children, target: displayNode.children, index: 0 });\n }\n }\n return { tree, rawCopyText, savedLabels };\n}\n\nfunction sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {\n switch (entry.type) {\n case \"message\": {\n const message = { ...entry.message } as Record<string, unknown>;\n if (\"content\" in entry.message) message.content = sanitizeDisplayContent(entry.message.content);\n for (const key of [\"role\", \"errorMessage\", \"command\", \"toolName\"] as const) {\n const value = message[key];\n if (typeof value === \"string\") message[key] = sanitizeSingleLine(value);\n }\n return { ...entry, message } as unknown as SessionEntry;\n }\n case \"custom_message\":\n return {\n ...entry,\n customType: sanitizeSingleLine(entry.customType),\n content: sanitizeDisplayContent(entry.content) as typeof entry.content,\n };\n case \"compaction\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"branch_summary\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"model_change\":\n return {\n ...entry,\n provider: sanitizeSingleLine(entry.provider),\n modelId: sanitizeSingleLine(entry.modelId),\n };\n case \"thinking_level_change\":\n return { ...entry, thinkingLevel: sanitizeSingleLine(entry.thinkingLevel) };\n case \"custom\":\n return { ...entry, customType: sanitizeSingleLine(entry.customType) };\n case \"context_edit\":\n return { ...entry, targetId: sanitizeSingleLine(entry.targetId) };\n case \"label\":\n return {\n ...entry,\n label: entry.label === undefined ? undefined : sanitizeSingleLine(entry.label),\n };\n case \"session_info\":\n return {\n ...entry,\n name: entry.name === undefined ? undefined : sanitizeSingleLine(entry.name),\n };\n case \"usage\":\n return {\n ...entry,\n kind: sanitizeSingleLine(entry.kind),\n provider: sanitizeSingleLine(entry.provider),\n model: sanitizeSingleLine(entry.model),\n note: entry.note === undefined ? undefined : sanitizeSingleLine(entry.note),\n };\n }\n}\n\nfunction sanitizeDisplayContent(content: unknown): unknown {\n if (typeof content === \"string\") return sanitizeSingleLine(content);\n if (!Array.isArray(content)) return content;\n return content.map((block) => {\n if (block === null || typeof block !== \"object\" || !(\"type\" in block)) return block;\n if (block.type === \"text\" && \"text\" in block && typeof block.text === \"string\") {\n return { ...block, text: sanitizeSingleLine(block.text) };\n }\n if (block.type === \"toolCall\") {\n const copy = { ...block } as Record<string, unknown>;\n if (typeof copy.name === \"string\") copy.name = sanitizeSingleLine(copy.name);\n copy.arguments = sanitizeToolArguments(copy.arguments, new WeakMap());\n return copy;\n }\n return block;\n });\n}\n\nfunction sanitizeToolArguments(value: unknown, seen: WeakMap<object, unknown>): unknown {\n if (typeof value === \"string\") return sanitizeSingleLine(value);\n if (value === null || typeof value !== \"object\") return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n for (const item of value) result.push(sanitizeToolArguments(item, seen));\n return result;\n }\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n for (const [key, item] of Object.entries(value)) {\n result[key] = sanitizeToolArguments(item, seen);\n }\n return result;\n}\n\nfunction getRawCopyText(entry: SessionEntry): string | undefined {\n let text: string | undefined;\n if (entry.type === \"message\") {\n if (entry.message.role === \"bashExecution\") text = entry.message.command;\n else if (\"content\" in entry.message) {\n text = extractRawText(entry.message.content);\n if (!text && entry.message.role === \"assistant\") text = entry.message.errorMessage;\n }\n } else if (entry.type === \"custom_message\") text = extractRawText(entry.content);\n else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") text = entry.summary;\n return text?.trim() ? text : undefined;\n}\n\nfunction extractRawText(content: unknown): string {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n return content\n .filter(\n (block): block is { type: \"text\"; text: string } =>\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\",\n )\n .map((block) => block.text)\n .join(\"\");\n}\n\ninterface SavedLabel {\n label: string | undefined;\n labelTimestamp?: string;\n}\n\nasync function copyText(text: string, signal: AbortSignal): Promise<void> {\n signal.throwIfAborted();\n await copyToClipboard(text);\n signal.throwIfAborted();\n}\n\nfunction notifySafely(\n ctx: ExtensionCommandContext,\n message: string,\n level: Parameters<ExtensionCommandContext[\"ui\"][\"notify\"]>[1],\n): void {\n try {\n ctx.ui.notify(sanitizeSingleLine(message), level);\n } catch {\n // The command context may have been replaced while the selector was open.\n }\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAKA;AAAA,OACK;AACP,SAAyC,KAAK,kBAAkB;AA2BhE,IAAM,gCAAN,MAAoE;AAAA,EAClE,YACmB,UACA,SACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EAGnB,IAAI,UAAmB;AACrB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,IAAI,QAAQ,OAAgB;AAC1B,SAAK,SAAS,UAAU;AAAA,EAC1B;AAAA,EAEA,IAAI,kBAAuC;AACzC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,OAAO,OAAyB;AAC9B,WAAO,KAAK,SAAS,OAAO,KAAK;AAAA,EACnC;AAAA,EAEA,YAAY,MAAoB;AAC9B,QAAI,WAAW,MAAM,IAAI,KAAK,GAAG,CAAC,GAAG;AACnC,WAAK,QAAQ;AACb;AAAA,IACF;AACA,SAAK,SAAS,cAAc,IAAI;AAAA,EAClC;AAAA,EAEA,aAAmB;AACjB,SAAK,SAAS,WAAW;AAAA,EAC3B;AAAA,EAEA,UAAgB;AACd,SAAK,SAAS,UAAU;AACxB,SAAK,QAAQ;AAAA,EACf;AACF;AAEA,eAAsB,cACpB,IACA,KACA,eAAiD,CAAC,GACpB;AAC9B,MAAI;AACJ,M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AAO,QACJ;AAAA,IACC,CAAC,UACC,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,UACf,UAAU,SACV,OAAO,MAAM,SAAS;AAAA,EAC1B,EACC,IAAI,CAAC,UAAU,MAAM,IAAI,EACzB,KAAK,EAAE;AACZ;AAOA,eAAe,SAAS,MAAc,QAAoC;AACxE,SAAO,eAAe;AACtB,QAAM,gBAAgB,IAAI;AAC1B,SAAO,eAAe;AACxB;AAEA,SAAS,aACP,KACA,SACA,OACM;AACN,MAAI;AACF,QAAI,GAAG,OAAO,mBAAmB,OAAO,GAAG,KAAK;AAAA,EAClD,QAAQ;AAAA,EAER;AACF;AAEA,SAAS,YAAY,OAAwB;AAC3C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
|
|
6
|
+
"names": ["result"]
|
|
7
|
+
}
|
package/dist/index.ts
CHANGED
|
@@ -217,7 +217,7 @@ var runFullscreenOnFirstUse = async (ctx, run, options) => {
|
|
|
217
217
|
return runBtwFullscreen(ctx, run, options);
|
|
218
218
|
};
|
|
219
219
|
var pickEntryOnFirstUse = async (pi, ctx) => {
|
|
220
|
-
const { pickMainEntry } = await import("./chunks/main-tree-picker-
|
|
220
|
+
const { pickMainEntry } = await import("./chunks/main-tree-picker-YEHPIYZP.ts");
|
|
221
221
|
if (ctx.signal?.aborted) return { kind: "closed" };
|
|
222
222
|
return pickMainEntry(pi, ctx);
|
|
223
223
|
};
|
package/package.json
CHANGED
package/src/main-tree-picker.ts
CHANGED
|
@@ -92,9 +92,7 @@ export async function pickMainEntry(
|
|
|
92
92
|
return { kind: "back" };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const tree =
|
|
96
|
-
const rawCopyText = collectRawCopyText(rawTree);
|
|
97
|
-
const savedLabels = collectSavedLabels(rawTree);
|
|
95
|
+
const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);
|
|
98
96
|
const createSelector = dependencies.createSelector ?? createNativeTreeSelector;
|
|
99
97
|
const copy = dependencies.copyToClipboard ?? copyText;
|
|
100
98
|
const copyControllers = new Set<AbortController>();
|
|
@@ -200,18 +198,40 @@ function createNativeTreeSelector(options: MainThreadTreeSelectorOptions): MainT
|
|
|
200
198
|
return result;
|
|
201
199
|
}
|
|
202
200
|
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
function prepareTreeSnapshot(rawTree: readonly SessionTreeNode[]): {
|
|
202
|
+
tree: SessionTreeNode[];
|
|
203
|
+
rawCopyText: Map<string, string>;
|
|
204
|
+
savedLabels: Map<string, SavedLabel>;
|
|
205
|
+
} {
|
|
206
|
+
const tree: SessionTreeNode[] = [];
|
|
207
|
+
const rawCopyText = new Map<string, string>();
|
|
208
|
+
const savedLabels = new Map<string, SavedLabel>();
|
|
209
|
+
// Keep traversal state on the heap: valid session histories can be arbitrarily deep.
|
|
210
|
+
const stack = [{ source: rawTree, target: tree, index: 0 }];
|
|
211
|
+
while (stack.length > 0) {
|
|
212
|
+
const frame = stack[stack.length - 1];
|
|
213
|
+
if (frame.index === frame.source.length) {
|
|
214
|
+
stack.pop();
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const node = frame.source[frame.index++];
|
|
218
|
+
const label = node.label === undefined ? undefined : sanitizeSingleLine(node.label);
|
|
219
|
+
const labelTimestamp = node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp);
|
|
220
|
+
const displayNode: SessionTreeNode = {
|
|
206
221
|
entry: sanitizeEntryForDisplay(node.entry),
|
|
207
|
-
children:
|
|
222
|
+
children: [],
|
|
208
223
|
};
|
|
209
|
-
if (
|
|
210
|
-
if (
|
|
211
|
-
|
|
224
|
+
if (label !== undefined) displayNode.label = label;
|
|
225
|
+
if (labelTimestamp !== undefined) displayNode.labelTimestamp = labelTimestamp;
|
|
226
|
+
frame.target.push(displayNode);
|
|
227
|
+
const text = getRawCopyText(node.entry);
|
|
228
|
+
if (text !== undefined) rawCopyText.set(node.entry.id, text);
|
|
229
|
+
savedLabels.set(node.entry.id, { label, labelTimestamp });
|
|
230
|
+
if (node.children.length > 0) {
|
|
231
|
+
stack.push({ source: node.children, target: displayNode.children, index: 0 });
|
|
212
232
|
}
|
|
213
|
-
|
|
214
|
-
}
|
|
233
|
+
}
|
|
234
|
+
return { tree, rawCopyText, savedLabels };
|
|
215
235
|
}
|
|
216
236
|
|
|
217
237
|
function sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {
|
|
@@ -305,19 +325,6 @@ function sanitizeToolArguments(value: unknown, seen: WeakMap<object, unknown>):
|
|
|
305
325
|
return result;
|
|
306
326
|
}
|
|
307
327
|
|
|
308
|
-
function collectRawCopyText(tree: readonly SessionTreeNode[]): Map<string, string> {
|
|
309
|
-
const result = new Map<string, string>();
|
|
310
|
-
const visit = (nodes: readonly SessionTreeNode[]) => {
|
|
311
|
-
for (const node of nodes) {
|
|
312
|
-
const text = getRawCopyText(node.entry);
|
|
313
|
-
if (text !== undefined) result.set(node.entry.id, text);
|
|
314
|
-
visit(node.children);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
visit(tree);
|
|
318
|
-
return result;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
328
|
function getRawCopyText(entry: SessionEntry): string | undefined {
|
|
322
329
|
let text: string | undefined;
|
|
323
330
|
if (entry.type === "message") {
|
|
@@ -353,21 +360,6 @@ interface SavedLabel {
|
|
|
353
360
|
labelTimestamp?: string;
|
|
354
361
|
}
|
|
355
362
|
|
|
356
|
-
function collectSavedLabels(tree: readonly SessionTreeNode[]): Map<string, SavedLabel> {
|
|
357
|
-
const result = new Map<string, SavedLabel>();
|
|
358
|
-
const visit = (nodes: readonly SessionTreeNode[]) => {
|
|
359
|
-
for (const node of nodes) {
|
|
360
|
-
result.set(node.entry.id, {
|
|
361
|
-
label: node.label === undefined ? undefined : sanitizeSingleLine(node.label),
|
|
362
|
-
labelTimestamp: node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp),
|
|
363
|
-
});
|
|
364
|
-
visit(node.children);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
visit(tree);
|
|
368
|
-
return result;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
363
|
async function copyText(text: string, signal: AbortSignal): Promise<void> {
|
|
372
364
|
signal.throwIfAborted();
|
|
373
365
|
await copyToClipboard(text);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/main-tree-picker.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n copyToClipboard,\n type ExtensionAPI,\n type ExtensionCommandContext,\n type SessionEntry,\n type SessionTreeNode,\n TreeSelectorComponent,\n} from \"@earendil-works/pi-coding-agent\";\nimport { type Component, type Focusable, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { showBtwCustomPreservingEditor } from \"./menu.js\";\nimport { sanitizeSingleLine } from \"./text.js\";\n\nexport type MainEntryPickResult = { kind: \"selected\"; entryId: string } | { kind: \"back\" } | { kind: \"closed\" };\n\nexport interface MainThreadTreeSelector extends Component, Focusable {\n onCopy?: (text: string | undefined) => void;\n setViewLabel?(entryId: string, label: string | undefined, labelTimestamp?: string): void;\n dispose?(): void;\n}\n\nexport interface MainThreadTreeSelectorOptions {\n tree: SessionTreeNode[];\n currentLeafId: string | null;\n terminalRows: number;\n onSelect: (entryId: string) => void;\n onCancel: () => void;\n onCopy: (entryId: string | undefined, displayText: string | undefined) => void;\n onLabelChange: (entryId: string, label: string | undefined) => void;\n}\n\nexport interface MainThreadTreePickerDependencies {\n createSelector?: (options: MainThreadTreeSelectorOptions) => MainThreadTreeSelector;\n copyToClipboard?: (text: string, signal: AbortSignal) => Promise<void>;\n}\n\nclass MainThreadTreePickerComponent implements Component, Focusable {\n constructor(\n private readonly selector: MainThreadTreeSelector,\n private readonly onClose: () => void,\n ) {}\n\n get focused(): boolean {\n return this.selector.focused;\n }\n\n set focused(value: boolean) {\n this.selector.focused = value;\n }\n\n get wantsKeyRelease(): boolean | undefined {\n return this.selector.wantsKeyRelease;\n }\n\n render(width: number): string[] {\n return this.selector.render(width);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n this.onClose();\n return;\n }\n this.selector.handleInput?.(data);\n }\n\n invalidate(): void {\n this.selector.invalidate();\n }\n\n dispose(): void {\n this.selector.dispose?.();\n this.onClose();\n }\n}\n\nexport async function pickMainEntry(\n pi: ExtensionAPI,\n ctx: ExtensionCommandContext,\n dependencies: MainThreadTreePickerDependencies = {},\n): Promise<MainEntryPickResult> {\n let rawTree: SessionTreeNode[];\n let currentLeafId: string | null;\n try {\n rawTree = ctx.sessionManager.getTree();\n currentLeafId = ctx.sessionManager.getLeafId();\n } catch {\n return { kind: \"closed\" };\n }\n\n if (rawTree.length === 0) {\n notifySafely(ctx, \"No main-thread entries are available\", \"warning\");\n return { kind: \"back\" };\n }\n\n const tree = sanitizeTreeForDisplay(rawTree);\n const rawCopyText = collectRawCopyText(rawTree);\n const savedLabels = collectSavedLabels(rawTree);\n const createSelector = dependencies.createSelector ?? createNativeTreeSelector;\n const copy = dependencies.copyToClipboard ?? copyText;\n const copyControllers = new Set<AbortController>();\n const copyTasks = new Set<Promise<void>>();\n const abortCopies = () => {\n for (const controller of copyControllers) {\n controller.abort(new Error(\"The main-thread tree picker closed\"));\n }\n };\n const result = await showBtwCustomPreservingEditor<MainEntryPickResult>(ctx, (tui, _theme, _keybindings, done) => {\n let settled = false;\n let selector: MainThreadTreeSelector | undefined;\n const finish = (value: MainEntryPickResult) => {\n if (settled) return;\n settled = true;\n abortCopies();\n done(value);\n };\n const onCopy = (entryId: string | undefined, displayText: string | undefined) => {\n if (settled) return;\n const text = entryId ? rawCopyText.get(entryId) : displayText;\n if (!text) {\n notifySafely(ctx, \"Selected entry has no text to copy\", \"warning\");\n return;\n }\n const controller = new AbortController();\n copyControllers.add(controller);\n let operation: Promise<void>;\n try {\n operation = copy(text, controller.signal);\n } catch (error: unknown) {\n operation = Promise.reject(error);\n }\n let task!: Promise<void>;\n task = operation\n .then(() => {\n if (!settled) notifySafely(ctx, \"Copied selected message\", \"info\");\n })\n .catch((error: unknown) => {\n if (!settled && !controller.signal.aborted) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n }\n })\n .finally(() => {\n copyControllers.delete(controller);\n copyTasks.delete(task);\n });\n copyTasks.add(task);\n };\n const restoreLabel = (entryId: string) => {\n const previous = savedLabels.get(entryId);\n selector?.setViewLabel?.(entryId, previous?.label, previous?.labelTimestamp);\n tui.requestRender();\n };\n const onLabelChange = (entryId: string, label: string | undefined) => {\n if (settled) return;\n try {\n if (!ctx.sessionManager.getEntry(entryId)) {\n restoreLabel(entryId);\n notifySafely(ctx, \"The selected main-thread entry is no longer available\", \"warning\");\n return;\n }\n const persistedLabel = label === undefined ? undefined : sanitizeSingleLine(label);\n pi.setLabel(entryId, persistedLabel);\n savedLabels.set(entryId, { label: persistedLabel });\n selector?.setViewLabel?.(entryId, persistedLabel);\n tui.requestRender();\n } catch (error: unknown) {\n restoreLabel(entryId);\n notifySafely(ctx, `Could not update tree label: ${formatError(error)}`, \"error\");\n }\n };\n selector = createSelector({\n tree,\n currentLeafId,\n terminalRows: tui.terminal.rows,\n onSelect: (entryId) => finish({ kind: \"selected\", entryId }),\n onCancel: () => finish({ kind: \"back\" }),\n onCopy,\n onLabelChange,\n });\n return new MainThreadTreePickerComponent(selector, () => finish({ kind: \"closed\" }));\n });\n abortCopies();\n await Promise.allSettled([...copyTasks]);\n\n return result ?? { kind: \"closed\" };\n}\n\nfunction createNativeTreeSelector(options: MainThreadTreeSelectorOptions): MainThreadTreeSelector {\n const selector = new TreeSelectorComponent(\n options.tree,\n options.currentLeafId,\n options.terminalRows,\n options.onSelect,\n options.onCancel,\n options.onLabelChange,\n );\n selector.onCopy = (displayText) => options.onCopy(selector.getTreeList().getSelectedNode()?.entry.id, displayText);\n const result = selector as MainThreadTreeSelector;\n result.setViewLabel = (entryId, label, labelTimestamp) =>\n selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);\n return result;\n}\n\nfunction sanitizeTreeForDisplay(tree: readonly SessionTreeNode[]): SessionTreeNode[] {\n return tree.map((node) => {\n const result: SessionTreeNode = {\n entry: sanitizeEntryForDisplay(node.entry),\n children: sanitizeTreeForDisplay(node.children),\n };\n if (node.label !== undefined) result.label = sanitizeSingleLine(node.label);\n if (node.labelTimestamp !== undefined) {\n result.labelTimestamp = sanitizeSingleLine(node.labelTimestamp);\n }\n return result;\n });\n}\n\nfunction sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {\n switch (entry.type) {\n case \"message\": {\n const message = { ...entry.message } as Record<string, unknown>;\n if (\"content\" in entry.message) message.content = sanitizeDisplayContent(entry.message.content);\n for (const key of [\"role\", \"errorMessage\", \"command\", \"toolName\"] as const) {\n const value = message[key];\n if (typeof value === \"string\") message[key] = sanitizeSingleLine(value);\n }\n return { ...entry, message } as unknown as SessionEntry;\n }\n case \"custom_message\":\n return {\n ...entry,\n customType: sanitizeSingleLine(entry.customType),\n content: sanitizeDisplayContent(entry.content) as typeof entry.content,\n };\n case \"compaction\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"branch_summary\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"model_change\":\n return {\n ...entry,\n provider: sanitizeSingleLine(entry.provider),\n modelId: sanitizeSingleLine(entry.modelId),\n };\n case \"thinking_level_change\":\n return { ...entry, thinkingLevel: sanitizeSingleLine(entry.thinkingLevel) };\n case \"custom\":\n return { ...entry, customType: sanitizeSingleLine(entry.customType) };\n case \"context_edit\":\n return { ...entry, targetId: sanitizeSingleLine(entry.targetId) };\n case \"label\":\n return {\n ...entry,\n label: entry.label === undefined ? undefined : sanitizeSingleLine(entry.label),\n };\n case \"session_info\":\n return {\n ...entry,\n name: entry.name === undefined ? undefined : sanitizeSingleLine(entry.name),\n };\n case \"usage\":\n return {\n ...entry,\n kind: sanitizeSingleLine(entry.kind),\n provider: sanitizeSingleLine(entry.provider),\n model: sanitizeSingleLine(entry.model),\n note: entry.note === undefined ? undefined : sanitizeSingleLine(entry.note),\n };\n }\n}\n\nfunction sanitizeDisplayContent(content: unknown): unknown {\n if (typeof content === \"string\") return sanitizeSingleLine(content);\n if (!Array.isArray(content)) return content;\n return content.map((block) => {\n if (block === null || typeof block !== \"object\" || !(\"type\" in block)) return block;\n if (block.type === \"text\" && \"text\" in block && typeof block.text === \"string\") {\n return { ...block, text: sanitizeSingleLine(block.text) };\n }\n if (block.type === \"toolCall\") {\n const copy = { ...block } as Record<string, unknown>;\n if (typeof copy.name === \"string\") copy.name = sanitizeSingleLine(copy.name);\n copy.arguments = sanitizeToolArguments(copy.arguments, new WeakMap());\n return copy;\n }\n return block;\n });\n}\n\nfunction sanitizeToolArguments(value: unknown, seen: WeakMap<object, unknown>): unknown {\n if (typeof value === \"string\") return sanitizeSingleLine(value);\n if (value === null || typeof value !== \"object\") return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n for (const item of value) result.push(sanitizeToolArguments(item, seen));\n return result;\n }\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n for (const [key, item] of Object.entries(value)) {\n result[key] = sanitizeToolArguments(item, seen);\n }\n return result;\n}\n\nfunction collectRawCopyText(tree: readonly SessionTreeNode[]): Map<string, string> {\n const result = new Map<string, string>();\n const visit = (nodes: readonly SessionTreeNode[]) => {\n for (const node of nodes) {\n const text = getRawCopyText(node.entry);\n if (text !== undefined) result.set(node.entry.id, text);\n visit(node.children);\n }\n };\n visit(tree);\n return result;\n}\n\nfunction getRawCopyText(entry: SessionEntry): string | undefined {\n let text: string | undefined;\n if (entry.type === \"message\") {\n if (entry.message.role === \"bashExecution\") text = entry.message.command;\n else if (\"content\" in entry.message) {\n text = extractRawText(entry.message.content);\n if (!text && entry.message.role === \"assistant\") text = entry.message.errorMessage;\n }\n } else if (entry.type === \"custom_message\") text = extractRawText(entry.content);\n else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") text = entry.summary;\n return text?.trim() ? text : undefined;\n}\n\nfunction extractRawText(content: unknown): string {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n return content\n .filter(\n (block): block is { type: \"text\"; text: string } =>\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\",\n )\n .map((block) => block.text)\n .join(\"\");\n}\n\ninterface SavedLabel {\n label: string | undefined;\n labelTimestamp?: string;\n}\n\nfunction collectSavedLabels(tree: readonly SessionTreeNode[]): Map<string, SavedLabel> {\n const result = new Map<string, SavedLabel>();\n const visit = (nodes: readonly SessionTreeNode[]) => {\n for (const node of nodes) {\n result.set(node.entry.id, {\n label: node.label === undefined ? undefined : sanitizeSingleLine(node.label),\n labelTimestamp: node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp),\n });\n visit(node.children);\n }\n };\n visit(tree);\n return result;\n}\n\nasync function copyText(text: string, signal: AbortSignal): Promise<void> {\n signal.throwIfAborted();\n await copyToClipboard(text);\n signal.throwIfAborted();\n}\n\nfunction notifySafely(\n ctx: ExtensionCommandContext,\n message: string,\n level: Parameters<ExtensionCommandContext[\"ui\"][\"notify\"]>[1],\n): void {\n try {\n ctx.ui.notify(sanitizeSingleLine(message), level);\n } catch {\n // The command context may have been replaced while the selector was open.\n }\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAKA;AAAA,OACK;AACP,SAAyC,KAAK,kBAAkB;AA2BhE,IAAM,gCAAN,MAAoE;AAAA,EAClE,YACmB,UACA,SACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EAGnB,IAAI,UAAmB;AACrB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