@aeondave/pi-persona-mind 0.8.7 → 0.9.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/AGENTS.md +58 -14
- package/CHANGELOG.md +95 -0
- package/README.md +123 -67
- package/docs/DESIGN.md +224 -35
- package/docs/MEMORY-RESEARCH.md +135 -112
- package/package.json +7 -12
- package/src/core/auto-optimize.ts +12 -10
- package/src/core/capture.ts +14 -6
- package/src/core/host-compat.ts +9 -6
- package/src/core/knowledge-review.ts +107 -0
- package/src/core/memory-inspector.ts +149 -0
- package/src/core/memory-read.ts +3 -3
- package/src/core/memory.ts +6 -0
- package/src/core/optimize-history.ts +3 -3
- package/src/core/optimize-service.ts +10 -6
- package/src/core/optimize.ts +5 -11
- package/src/core/retrieval.ts +5 -4
- package/src/core/service.ts +24 -13
- package/src/core/store.ts +8 -2
- package/src/extension/auto-optimize-session.ts +26 -6
- package/src/extension/auto-optimize.ts +134 -25
- package/src/extension/inspector-data.ts +69 -0
- package/src/extension/knowledge-review.ts +215 -0
- package/src/extension/memory-inspector.ts +82 -0
- package/src/extension/mind-actions.ts +38 -0
- package/src/extension/mind-command.ts +42 -1
- package/src/extension/review-evidence.ts +222 -0
- package/src/index.ts +90 -43
- package/src/session-memory.ts +6 -2
- package/src/tools/backlog.ts +2 -2
- package/src/tools/memory.ts +51 -24
- package/src/ui/card-frame.ts +161 -0
- package/src/ui/inspector-frame.ts +44 -0
- package/src/ui/memory-inspector.ts +460 -0
- package/src/ui/mind-result-card.ts +37 -4
- package/src/ui/presentation.ts +13 -23
- package/src/ui/session-note-card.ts +12 -6
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/** Lazy adapter for Persona's one versioned card-frame implementation. */
|
|
2
|
+
import type { EntryRenderOptions, ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { Text, type Component } from "@earendil-works/pi-tui";
|
|
4
|
+
import { compactVisibleText, sanitizeCardText } from "./presentation.ts";
|
|
5
|
+
|
|
6
|
+
export const CARD_FRAME_EVENT = "pi-persona:card-frame:v1";
|
|
7
|
+
|
|
8
|
+
export type CardFrameState = "neutral" | "success" | "attention" | "error";
|
|
9
|
+
|
|
10
|
+
export interface CardFramePreview {
|
|
11
|
+
text: string;
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CardFramePresentation {
|
|
16
|
+
title: string;
|
|
17
|
+
state: CardFrameState;
|
|
18
|
+
full: string;
|
|
19
|
+
preview: (width: number) => CardFramePreview;
|
|
20
|
+
metadata?: string;
|
|
21
|
+
markdown?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CardFrameContext {
|
|
25
|
+
expanded: boolean;
|
|
26
|
+
theme: Theme;
|
|
27
|
+
outputPad: number;
|
|
28
|
+
detailHint: () => string;
|
|
29
|
+
expansionKey?: object;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type CardFrameFactory = (presentation: CardFramePresentation, context: CardFrameContext) => Component;
|
|
33
|
+
|
|
34
|
+
export interface CardFrameProviderResponse {
|
|
35
|
+
version: 1;
|
|
36
|
+
provider: "pi-persona";
|
|
37
|
+
createCard: CardFrameFactory;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CardFrameQuery {
|
|
41
|
+
version: 1;
|
|
42
|
+
respond: (response: CardFrameProviderResponse) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CardFrameEventBus {
|
|
46
|
+
emit(event: string, data: unknown): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface MindCardUI {
|
|
50
|
+
renderCard: CardFrameRenderer;
|
|
51
|
+
/** Read from Pi's current effective settings for every entry-render invocation. */
|
|
52
|
+
outputPad: () => 0 | 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type CardFrameRenderer = (presentation: CardFramePresentation, context: CardFrameContext) => Component;
|
|
56
|
+
|
|
57
|
+
const MAX_COLLAPSED_CARD_LINES = 3;
|
|
58
|
+
const CARD_HINT_ID = "app.tools.expand";
|
|
59
|
+
const CARD_HINT_DESCRIPTION = "to expand";
|
|
60
|
+
|
|
61
|
+
function plainObject(value: unknown): value is Record<string, unknown> {
|
|
62
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
63
|
+
const prototype = Object.getPrototypeOf(value);
|
|
64
|
+
return prototype === Object.prototype || prototype === null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function validFactory(value: unknown): CardFrameFactory | undefined {
|
|
68
|
+
if (!plainObject(value)) return undefined;
|
|
69
|
+
const keys = Reflect.ownKeys(value);
|
|
70
|
+
if (keys.length !== 3 || keys.some((key) => key !== "version" && key !== "provider" && key !== "createCard")) return undefined;
|
|
71
|
+
if (value.version !== 1 || value.provider !== "pi-persona" || typeof value.createCard !== "function") return undefined;
|
|
72
|
+
return value.createCard as CardFrameFactory;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isComponent(value: unknown): value is Component {
|
|
76
|
+
return !!value && typeof value === "object"
|
|
77
|
+
&& typeof (value as { render?: unknown }).render === "function"
|
|
78
|
+
&& typeof (value as { invalidate?: unknown }).invalidate === "function";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** No second styling system: if Persona is absent or unsafe, show complete sanitized plaintext. */
|
|
82
|
+
function plaintextFallback(presentation: CardFramePresentation): Component {
|
|
83
|
+
const title = sanitizeCardText(presentation.title).trim();
|
|
84
|
+
const safeFull = sanitizeCardText(presentation.full);
|
|
85
|
+
const full = safeFull.length > 0 ? safeFull : "(no output)";
|
|
86
|
+
return new Text(title ? `${title}\n${full}` : full, 0, 0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function queryFactory(events: CardFrameEventBus): CardFrameFactory | undefined {
|
|
90
|
+
let synchronous = true;
|
|
91
|
+
let responseCount = 0;
|
|
92
|
+
let factory: CardFrameFactory | undefined;
|
|
93
|
+
const query: CardFrameQuery = {
|
|
94
|
+
version: 1,
|
|
95
|
+
respond(response) {
|
|
96
|
+
if (!synchronous) return;
|
|
97
|
+
const candidate = validFactory(response);
|
|
98
|
+
if (!candidate) return;
|
|
99
|
+
responseCount++;
|
|
100
|
+
factory = candidate;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
try {
|
|
104
|
+
events.emit(CARD_FRAME_EVENT, query);
|
|
105
|
+
} catch {
|
|
106
|
+
return undefined;
|
|
107
|
+
} finally {
|
|
108
|
+
synchronous = false;
|
|
109
|
+
}
|
|
110
|
+
return responseCount === 1 ? factory : undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Bind one UI adapter to one extension instance. The shared factory lookup is intentionally fresh
|
|
115
|
+
* for every render so extension load order, reload and provider replacement are observed.
|
|
116
|
+
*/
|
|
117
|
+
export function createMindCardUI(pi: Pick<ExtensionAPI, "events" | "getSettings">): MindCardUI {
|
|
118
|
+
const renderCard: CardFrameRenderer = (presentation, context) => {
|
|
119
|
+
const fallback = () => plaintextFallback(presentation);
|
|
120
|
+
try {
|
|
121
|
+
const factory = queryFactory(pi.events);
|
|
122
|
+
if (!factory) return fallback();
|
|
123
|
+
const component = factory(presentation, context);
|
|
124
|
+
return isComponent(component) ? component : fallback();
|
|
125
|
+
} catch {
|
|
126
|
+
return fallback();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
renderCard,
|
|
131
|
+
outputPad: () => {
|
|
132
|
+
try {
|
|
133
|
+
return pi.getSettings().outputPad === 0 ? 0 : 1;
|
|
134
|
+
} catch {
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Build the shared-frame presentation without changing the persisted/history payload. */
|
|
142
|
+
export function cardFramePresentation(title: string, full: string, compactSummary?: string): CardFramePresentation {
|
|
143
|
+
const previewSource = compactSummary ?? full;
|
|
144
|
+
return {
|
|
145
|
+
title,
|
|
146
|
+
state: "neutral",
|
|
147
|
+
full,
|
|
148
|
+
preview(width) {
|
|
149
|
+
const previewWidth = Number.isFinite(width) ? Math.max(1, Math.floor(width)) : 96;
|
|
150
|
+
const preview = compactVisibleText(previewSource, {
|
|
151
|
+
maxLines: MAX_COLLAPSED_CARD_LINES,
|
|
152
|
+
maxLineChars: previewWidth,
|
|
153
|
+
});
|
|
154
|
+
return { text: preview.text, truncated: compactSummary !== undefined || preview.truncated };
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function cardFrameDetailHint(keyHint: EntryRenderOptions["keyHint"]): () => string {
|
|
160
|
+
return () => keyHint(CARD_HINT_ID, CARD_HINT_DESCRIPTION);
|
|
161
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Structural adapter to Persona's shared, stateless inspector frame. */
|
|
2
|
+
export const INSPECTOR_FRAME_EVENT = "pi-persona:inspector-frame:v1";
|
|
3
|
+
|
|
4
|
+
export interface InspectorLayout {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
contentWidth: number;
|
|
8
|
+
contentRows: number;
|
|
9
|
+
gutter: number;
|
|
10
|
+
framed: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InspectorFrame {
|
|
14
|
+
viewportRows(terminalRows: number): number;
|
|
15
|
+
layout(width: number, height: number): InspectorLayout;
|
|
16
|
+
render(lines: readonly string[], layout: InspectorLayout, border: (text: string) => string): string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface InspectorFrameEventBus { emit(event: string, data: unknown): void; }
|
|
20
|
+
|
|
21
|
+
function validFrame(response: unknown): InspectorFrame | undefined {
|
|
22
|
+
if (!response || typeof response !== "object") return undefined;
|
|
23
|
+
const value = response as Record<string, unknown>;
|
|
24
|
+
if (value.version !== 1 || value.provider !== "pi-persona" || !value.frame || typeof value.frame !== "object") return undefined;
|
|
25
|
+
const frame = value.frame as Record<string, unknown>;
|
|
26
|
+
return typeof frame.viewportRows === "function" && typeof frame.layout === "function" && typeof frame.render === "function"
|
|
27
|
+
? value.frame as InspectorFrame : undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Resolve on each opening; late and ambiguous providers cannot select a renderer. */
|
|
31
|
+
export function queryInspectorFrame(events: InspectorFrameEventBus): InspectorFrame | undefined {
|
|
32
|
+
let synchronous = true;
|
|
33
|
+
let count = 0;
|
|
34
|
+
let frame: InspectorFrame | undefined;
|
|
35
|
+
try {
|
|
36
|
+
events.emit(INSPECTOR_FRAME_EVENT, { version: 1, respond(response: unknown) {
|
|
37
|
+
if (!synchronous) return;
|
|
38
|
+
const candidate = validFrame(response);
|
|
39
|
+
if (candidate) { count++; frame = candidate; }
|
|
40
|
+
} });
|
|
41
|
+
} catch { return undefined; }
|
|
42
|
+
finally { synchronous = false; }
|
|
43
|
+
return count === 1 ? frame : undefined;
|
|
44
|
+
}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { getKeybindings, setKeybindings, Input, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component, type Focusable, type TUI, type KeybindingsManager } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { InspectorItem, InspectorPage, InspectorRequest, InspectorScope, InspectorTab } from "../extension/inspector-data.ts";
|
|
4
|
+
import { sanitizeCardText } from "./presentation.ts";
|
|
5
|
+
import type { InspectorFrame } from "./inspector-frame.ts";
|
|
6
|
+
|
|
7
|
+
const TABS: InspectorTab[] = ["memories", "context", "timeline"];
|
|
8
|
+
const TAB_LABELS: Record<InspectorTab, string> = { memories: "Memories", context: "Context", timeline: "Timeline" };
|
|
9
|
+
const SCOPES: InspectorScope[] = ["session", "project", "project-long", "persona", "shared"];
|
|
10
|
+
|
|
11
|
+
export interface MemoryInspectorOptions {
|
|
12
|
+
frame?: InspectorFrame;
|
|
13
|
+
load: (request: InspectorRequest) => Promise<InspectorPage>;
|
|
14
|
+
isCurrent: () => boolean;
|
|
15
|
+
initialTab?: InspectorTab;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
/** Allocated overlay rows; matches the host overlay maxHeight after margins. */
|
|
18
|
+
viewportHeight?: () => number;
|
|
19
|
+
onAction?: (request: InspectorRequest & { selectedId?: string }) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type View = "list" | "detail" | "source" | "help";
|
|
23
|
+
|
|
24
|
+
export class MemoryInspectorComponent implements Component, Focusable {
|
|
25
|
+
private tab: InspectorTab;
|
|
26
|
+
private scope: InspectorScope = "session";
|
|
27
|
+
private query = "";
|
|
28
|
+
private _focused = false;
|
|
29
|
+
private helpReturn: Exclude<View, "help"> = "list";
|
|
30
|
+
private sourceReturn: "list" | "detail" = "list";
|
|
31
|
+
private helpScroll = 0;
|
|
32
|
+
private wrappedCache: { width: number; body: string; lines: string[] } | undefined;
|
|
33
|
+
private page: InspectorPage | undefined;
|
|
34
|
+
private selected = 0;
|
|
35
|
+
private view: View = "list";
|
|
36
|
+
private item: InspectorItem | undefined;
|
|
37
|
+
private offsets: number[] = [0];
|
|
38
|
+
private generation = 0;
|
|
39
|
+
private closed = false;
|
|
40
|
+
private loading = true;
|
|
41
|
+
private error = "";
|
|
42
|
+
private searching = false;
|
|
43
|
+
private detailScroll = 0;
|
|
44
|
+
private sourceScroll = 0;
|
|
45
|
+
private listStart = 0;
|
|
46
|
+
private listCapacity = 1;
|
|
47
|
+
private detailCapacity = 1;
|
|
48
|
+
private readonly frame: InspectorFrame;
|
|
49
|
+
private readonly searchInput = new Input({ prompt: "/ " });
|
|
50
|
+
private pendingAction: (InspectorRequest & { selectedId?: string }) | undefined;
|
|
51
|
+
|
|
52
|
+
get focused(): boolean { return this._focused; }
|
|
53
|
+
set focused(value: boolean) { this._focused = value; this.searchInput.focused = value && this.searching; }
|
|
54
|
+
readonly capturesViewportInput = true;
|
|
55
|
+
private readonly onAbort: () => void;
|
|
56
|
+
private readonly tui: TUI;
|
|
57
|
+
private readonly theme: { fg(name: "accent" | "border" | "dim" | "warning" | "error" | "success", text: string): string; bold(text: string): string };
|
|
58
|
+
private readonly keybindings: KeybindingsManager;
|
|
59
|
+
private readonly done: (result: void) => void;
|
|
60
|
+
private readonly options: MemoryInspectorOptions;
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
tui: TUI,
|
|
64
|
+
theme: { fg(name: "accent" | "border" | "dim" | "warning" | "error" | "success", text: string): string; bold(text: string): string },
|
|
65
|
+
keybindings: KeybindingsManager,
|
|
66
|
+
done: (result: void) => void,
|
|
67
|
+
options: MemoryInspectorOptions,
|
|
68
|
+
) {
|
|
69
|
+
this.tui = tui;
|
|
70
|
+
this.theme = theme;
|
|
71
|
+
this.keybindings = keybindings;
|
|
72
|
+
this.searchInput.onEscape = () => { this.setSearching(false); this.tui.requestRender(); };
|
|
73
|
+
this.searchInput.onSubmit = (value) => {
|
|
74
|
+
this.query = sanitizeCardText(value);
|
|
75
|
+
this.setSearching(false);
|
|
76
|
+
this.resetAndLoad();
|
|
77
|
+
this.tui.requestRender();
|
|
78
|
+
};
|
|
79
|
+
this.done = done;
|
|
80
|
+
this.options = options;
|
|
81
|
+
if (!options.frame) throw new Error("Inspector frame requires compatible loaded pi-persona");
|
|
82
|
+
this.frame = options.frame;
|
|
83
|
+
this.tab = options.initialTab ?? "memories";
|
|
84
|
+
this.onAbort = () => this.close();
|
|
85
|
+
if (options.signal?.aborted) this.close();
|
|
86
|
+
else options.signal?.addEventListener("abort", this.onAbort, { once: true });
|
|
87
|
+
if (!this.closed) this.startLoad();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private isCurrent(): boolean {
|
|
91
|
+
if (this.closed) return false;
|
|
92
|
+
if (!this.options.isCurrent()) { this.close(); return false; }
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private close(): void {
|
|
97
|
+
if (this.closed) return;
|
|
98
|
+
this.closed = true;
|
|
99
|
+
this.generation++;
|
|
100
|
+
this.options.signal?.removeEventListener("abort", this.onAbort);
|
|
101
|
+
this.done();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private request(): InspectorRequest {
|
|
105
|
+
return { tab: this.tab, scope: this.scope, query: this.query, offset: this.offsets.at(-1) ?? 0 };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private startLoad(): void {
|
|
109
|
+
const generation = ++this.generation;
|
|
110
|
+
this.loading = true;
|
|
111
|
+
this.error = "";
|
|
112
|
+
this.page = undefined;
|
|
113
|
+
this.selected = 0;
|
|
114
|
+
const req = this.request();
|
|
115
|
+
// Always consume rejections: input handlers and the component factory are synchronous.
|
|
116
|
+
void this.options.load(req).then((result) => {
|
|
117
|
+
if (!this.isCurrent() || generation !== this.generation) return;
|
|
118
|
+
this.page = result;
|
|
119
|
+
this.loading = false;
|
|
120
|
+
this.error = "";
|
|
121
|
+
this.selected = Math.min(this.selected, Math.max(0, result.items.length - 1));
|
|
122
|
+
this.tui.requestRender();
|
|
123
|
+
}, (error: unknown) => {
|
|
124
|
+
if (!this.isCurrent() || generation !== this.generation) return;
|
|
125
|
+
this.loading = false;
|
|
126
|
+
this.error = error instanceof Error ? error.message : "Unable to load inspector data";
|
|
127
|
+
this.tui.requestRender();
|
|
128
|
+
}).catch(() => { /* Keep the custom UI path free of unhandled callback failures. */ });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private resetAndLoad(): void { this.offsets = [0]; this.view = "list"; this.item = undefined; this.startLoad(); }
|
|
132
|
+
|
|
133
|
+
private switchTab(): void {
|
|
134
|
+
this.tab = TABS[(TABS.indexOf(this.tab) + 1) % TABS.length]!;
|
|
135
|
+
this.query = "";
|
|
136
|
+
this.searchInput.setValue("");
|
|
137
|
+
this.resetAndLoad();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
handleInput(data: string): void {
|
|
141
|
+
if (!this.isCurrent()) return;
|
|
142
|
+
if (matchesKey(data, "f10")) { this.close(); return; }
|
|
143
|
+
if (this.searching) {
|
|
144
|
+
const global = getKeybindings();
|
|
145
|
+
try {
|
|
146
|
+
if (global !== this.keybindings) setKeybindings(this.keybindings);
|
|
147
|
+
this.searchInput.handleInput(data);
|
|
148
|
+
} finally {
|
|
149
|
+
if (global !== this.keybindings) setKeybindings(global);
|
|
150
|
+
}
|
|
151
|
+
// Native Input owns paste buffering, but pasted terminal controls are not
|
|
152
|
+
// editor content. Strip them from the value before its next render.
|
|
153
|
+
const value = this.searchInput.getValue();
|
|
154
|
+
const clean = sanitizeCardText(value);
|
|
155
|
+
if (clean !== value) this.searchInput.setValue(clean);
|
|
156
|
+
this.tui.requestRender();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (this.keybindings.matches(data, "tui.select.cancel")) {
|
|
160
|
+
if (this.view === "source") this.view = this.sourceReturn;
|
|
161
|
+
else if (this.view === "detail") this.view = "list";
|
|
162
|
+
else if (this.view === "help") this.view = this.helpReturn;
|
|
163
|
+
else this.close();
|
|
164
|
+
this.tui.requestRender(); return;
|
|
165
|
+
}
|
|
166
|
+
if (this.view !== "list") {
|
|
167
|
+
if (data === "a" && this.tab === "memories" && this.view === "detail" && this.options.onAction) {
|
|
168
|
+
this.pendingAction = { ...this.request(), ...(this.item ? { selectedId: this.item.id } : {}) };
|
|
169
|
+
this.close();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const currentScroll = this.view === "source" ? this.sourceScroll : this.view === "help" ? this.helpScroll : this.detailScroll;
|
|
173
|
+
const delta = Math.max(1, this.detailCapacity - 1);
|
|
174
|
+
if (this.keybindings.matches(data, "tui.select.up")) this.setDetailScroll(Math.max(0, currentScroll - 1));
|
|
175
|
+
else if (this.keybindings.matches(data, "tui.select.down")) this.setDetailScroll(currentScroll + 1);
|
|
176
|
+
else if (this.keybindings.matches(data, "tui.select.pageUp") || this.keybindings.matches(data, "tui.altScreen.pageUp")) this.setDetailScroll(Math.max(0, currentScroll - delta));
|
|
177
|
+
else if (this.keybindings.matches(data, "tui.select.pageDown") || this.keybindings.matches(data, "tui.altScreen.pageDown")) this.setDetailScroll(currentScroll + delta);
|
|
178
|
+
else if (data === "s" && this.view === "detail" && this.item?.source) {
|
|
179
|
+
this.sourceReturn = "detail"; this.view = "source"; this.sourceScroll = 0;
|
|
180
|
+
} else if (data === "?" && this.view !== "help") {
|
|
181
|
+
this.helpReturn = this.view; this.helpScroll = 0; this.view = "help";
|
|
182
|
+
}
|
|
183
|
+
this.tui.requestRender(); return;
|
|
184
|
+
}
|
|
185
|
+
if (data === "a" && this.tab === "memories" && this.options.onAction) {
|
|
186
|
+
const selected = this.page?.items[this.selected];
|
|
187
|
+
this.pendingAction = { ...this.request(), ...(selected ? { selectedId: selected.id } : {}) };
|
|
188
|
+
this.close();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (matchesKey(data, "tab")) this.switchTab();
|
|
192
|
+
else if (matchesKey(data, "shift+tab")) {
|
|
193
|
+
this.tab = TABS[(TABS.indexOf(this.tab) + TABS.length - 1) % TABS.length]!;
|
|
194
|
+
this.query = ""; this.searchInput.setValue(""); this.resetAndLoad();
|
|
195
|
+
}
|
|
196
|
+
else if (this.keybindings.matches(data, "tui.select.up") && this.page) this.selected = Math.max(0, this.selected - 1);
|
|
197
|
+
else if (this.keybindings.matches(data, "tui.select.down") && this.page) this.selected = Math.max(0, Math.min(this.page.items.length - 1, this.selected + 1));
|
|
198
|
+
else if ((this.keybindings.matches(data, "tui.select.pageUp") || this.keybindings.matches(data, "tui.altScreen.pageUp")) && this.page) this.selected = Math.max(0, this.selected - this.listCapacity);
|
|
199
|
+
else if ((this.keybindings.matches(data, "tui.select.pageDown") || this.keybindings.matches(data, "tui.altScreen.pageDown")) && this.page) this.selected = Math.max(0, Math.min(this.page.items.length - 1, this.selected + this.listCapacity));
|
|
200
|
+
else if (this.keybindings.matches(data, "tui.select.confirm")) {
|
|
201
|
+
this.item = this.page?.items[this.selected]; if (this.item) { this.view = "detail"; this.detailScroll = 0; }
|
|
202
|
+
} else if (matchesKey(data, "left") && this.tab === "memories") {
|
|
203
|
+
this.scope = SCOPES[(SCOPES.indexOf(this.scope) + SCOPES.length - 1) % SCOPES.length]!; this.resetAndLoad();
|
|
204
|
+
} else if (matchesKey(data, "right") && this.tab === "memories") {
|
|
205
|
+
this.scope = SCOPES[(SCOPES.indexOf(this.scope) + 1) % SCOPES.length]!; this.resetAndLoad();
|
|
206
|
+
} else if (data === "/" && this.tab !== "context") {
|
|
207
|
+
this.searchInput.setValue(this.query); this.setSearching(true);
|
|
208
|
+
} else if (data === "?") {
|
|
209
|
+
this.helpReturn = "list"; this.helpScroll = 0; this.view = "help";
|
|
210
|
+
} else if (data === "s" && this.page?.items[this.selected]?.source) {
|
|
211
|
+
this.item = this.page.items[this.selected]; this.sourceReturn = "list"; this.view = "source"; this.sourceScroll = 0;
|
|
212
|
+
} else if (data === "n" && this.page?.nextOffset !== undefined) {
|
|
213
|
+
this.offsets.push(this.page.nextOffset); this.startLoad();
|
|
214
|
+
} else if (data === "p" && this.offsets.length > 1) {
|
|
215
|
+
this.offsets.pop(); this.startLoad();
|
|
216
|
+
} else if (data === "r") this.startLoad();
|
|
217
|
+
this.tui.requestRender();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private setSearching(value: boolean): void {
|
|
221
|
+
this.searching = value;
|
|
222
|
+
this.searchInput.focused = this.focused && value;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private setDetailScroll(offset: number): void {
|
|
226
|
+
if (this.view === "source") this.sourceScroll = offset;
|
|
227
|
+
else if (this.view === "help") this.helpScroll = offset;
|
|
228
|
+
else this.detailScroll = offset;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
render(width: number, height?: number): string[] {
|
|
232
|
+
if (!this.isCurrent() || width <= 0) return [];
|
|
233
|
+
const layout = this.frame.layout(width, height ?? this.options.viewportHeight?.() ?? this.tui.terminal?.rows ?? 1);
|
|
234
|
+
return this.frame.render(this.renderContent(layout.contentWidth, layout.contentRows), layout, (text) => this.theme.fg("border", text));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private renderContent(safeWidth: number, rows: number): string[] {
|
|
238
|
+
const t = this.theme;
|
|
239
|
+
const oneLine = (value: string) => sanitizeCardText(value).replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
|
|
240
|
+
const fit = (value: string) => truncateToWidth(value, safeWidth, "…");
|
|
241
|
+
const dim = (value: string) => t.fg("dim", fit(value));
|
|
242
|
+
const accent = (value: string) => t.fg("accent", fit(value));
|
|
243
|
+
const key = (action: "tui.select.up" | "tui.select.down" | "tui.select.confirm" | "tui.input.submit" | "tui.select.cancel" | "tui.select.pageUp" | "tui.select.pageDown") => {
|
|
244
|
+
const names = this.keybindings.getKeys(action);
|
|
245
|
+
return names.length ? names.map((name) => name.replace(/^pageUp$/i, "PgUp").replace(/^pageDown$/i, "PgDn").replace(/^escape$/i, "Esc").replace(/^return$/i, "Enter").replace(/(^|[+])([a-z])/g, (_match, prefix: string, letter: string) => `${prefix}${letter.toUpperCase()}`)).join("/") : "unbound";
|
|
246
|
+
};
|
|
247
|
+
const pair = (left: "tui.select.up" | "tui.select.down" | "tui.select.pageUp" | "tui.select.pageDown", right: "tui.select.up" | "tui.select.down" | "tui.select.pageUp" | "tui.select.pageDown") => {
|
|
248
|
+
const first = key(left);
|
|
249
|
+
const second = key(right);
|
|
250
|
+
return first === "unbound" || second === "unbound" ? "unbound" : `${first}/${second}`;
|
|
251
|
+
};
|
|
252
|
+
const selected = this.page?.items[this.selected];
|
|
253
|
+
const status = this.loading ? dim("Loading…") : this.error ? t.fg("error", fit(oneLine(this.error))) : undefined;
|
|
254
|
+
const result: string[] = [];
|
|
255
|
+
const footer = (parts: string[]) => wrapTextWithAnsi(parts.join(" · "), safeWidth).map(dim);
|
|
256
|
+
if (this.view === "list") {
|
|
257
|
+
this.listCapacity = 1;
|
|
258
|
+
const compactItems = this.page?.items ?? [];
|
|
259
|
+
const scopeNames: Record<InspectorScope, string> = { session: "Session", project: "Working", "project-long": "Project", persona: "Persona", shared: "Shared" };
|
|
260
|
+
const activeScope = this.tab === "memories" ? accent(t.bold(scopeNames[this.scope])) : accent(t.bold(TAB_LABELS[this.tab]));
|
|
261
|
+
if (this.searching) {
|
|
262
|
+
this.searchInput.focused = this.focused;
|
|
263
|
+
if (rows >= 3) result.push(accent(t.bold("Memory inspector")));
|
|
264
|
+
if (rows >= 7) result.push("");
|
|
265
|
+
if (rows >= 4) result.push(this.tab === "memories" ? `${dim("Scope: ")}${activeScope}` : activeScope);
|
|
266
|
+
result.push(this.searchInput.render(safeWidth)[0] ?? "/");
|
|
267
|
+
if (rows >= 7) result.push("");
|
|
268
|
+
if (rows >= 2) result.push(dim(`${key("tui.input.submit")} apply · ${key("tui.select.cancel")} cancel`));
|
|
269
|
+
return result.slice(0, rows).map(fit);
|
|
270
|
+
}
|
|
271
|
+
if (rows <= 4) {
|
|
272
|
+
const compact = compactItems[this.selected];
|
|
273
|
+
const selection = compact ? accent(`▸ ${oneLine(compact.title)}`) : this.loading ? dim("Loading…") : this.error ? t.fg("error", fit(oneLine(this.error))) : dim("No items");
|
|
274
|
+
if (rows === 1) result.push(selection);
|
|
275
|
+
else { result.push(activeScope); result.push(selection); }
|
|
276
|
+
return result.slice(0, rows).map(fit);
|
|
277
|
+
}
|
|
278
|
+
if (rows <= 9 || safeWidth < 20) {
|
|
279
|
+
result.push(accent(t.bold("Memory inspector")));
|
|
280
|
+
result.push(this.tab === "memories" ? `${dim("Scope: ")}${activeScope}` : activeScope);
|
|
281
|
+
const compact = compactItems[this.selected];
|
|
282
|
+
if (compact) result.push(accent(`▸ ${oneLine(compact.title)}`));
|
|
283
|
+
else if (this.loading) result.push(dim("Loading…"));
|
|
284
|
+
else if (this.error) result.push(t.fg("error", fit(oneLine(this.error))));
|
|
285
|
+
else result.push(dim("No items"));
|
|
286
|
+
if (rows >= 6 && compactItems.length) result.push(dim(`${(this.page?.offset ?? 0) + this.selected + 1} selected · ${(this.page?.offset ?? 0) + 1}-${(this.page?.offset ?? 0) + compactItems.length} of ${this.page?.total ?? 0}`));
|
|
287
|
+
if (rows >= 7) result.push(dim(`${pair("tui.select.up", "tui.select.down")} select · ${key("tui.select.confirm")} open · ${key("tui.select.cancel")}/F10 close`));
|
|
288
|
+
return result.slice(0, rows).map(fit);
|
|
289
|
+
}
|
|
290
|
+
result.push(accent(t.bold("Memory inspector")));
|
|
291
|
+
result.push(TABS.map((tab) => tab === this.tab ? accent(t.bold(`[${TAB_LABELS[tab]}]`)) : dim(TAB_LABELS[tab])).join(dim(" ")));
|
|
292
|
+
if (this.tab === "memories") {
|
|
293
|
+
const scopeStrip = safeWidth >= 72 ? ` · ${SCOPES.map((scope) => scope === this.scope ? accent(t.bold(`[${scopeNames[scope]}]`)) : dim(scopeNames[scope])).join(dim(" "))}` : "";
|
|
294
|
+
result.push(`${dim("Scope: ")}${activeScope}${scopeStrip}`);
|
|
295
|
+
} else result.push(dim(`Search: ${this.query ? oneLine(this.query) : "none"} · Tab switch clears search`));
|
|
296
|
+
if (this.tab === "memories") result.push(dim(`Search: ${this.query ? oneLine(this.query) : "none"} · Tab switch clears search`));
|
|
297
|
+
const items = this.page?.items ?? [];
|
|
298
|
+
const total = this.page?.total ?? 0;
|
|
299
|
+
const offset = this.page?.offset ?? 0;
|
|
300
|
+
const current = items.length ? `${offset + Math.min(this.selected + 1, items.length)} selected · ${offset + 1}-${offset + items.length} of ${total}` : `0 selected · 0 of ${total}`;
|
|
301
|
+
if (status) result.push(status);
|
|
302
|
+
result.push(dim(current));
|
|
303
|
+
if (this.page?.notice) result.push(dim("Coverage notice · ? help"));
|
|
304
|
+
if (!this.loading && !this.error && items.length === 0) result.push(dim("No items on this page."));
|
|
305
|
+
const optional: string[] = [];
|
|
306
|
+
if (this.tab === "memories") optional.push("←/→ scope");
|
|
307
|
+
if (this.tab !== "context") optional.push("/ search");
|
|
308
|
+
if (this.tab === "memories" && this.options.onAction) optional.push("a actions");
|
|
309
|
+
if (selected?.source) optional.push("s source");
|
|
310
|
+
if (this.page?.nextOffset !== undefined || this.offsets.length > 1) optional.push("n/p result pages");
|
|
311
|
+
let footers = [footer(["Tab / Shift+Tab tabs", ...optional.slice(0, 2)]), footer([`${pair("tui.select.up", "tui.select.down")} select`, `${key("tui.select.confirm")} open`, ...optional.slice(2, 4)]), footer(["? help", `${key("tui.select.cancel")}/F10 close`, ...optional.slice(4)])].flat();
|
|
312
|
+
if (rows - result.length - footers.length < 1) footers = [dim(`? help · ${key("tui.select.cancel")}/F10 close`)];
|
|
313
|
+
// Spend whitespace only when at least one record still fits. Match F9's
|
|
314
|
+
// title/content/footer separation rather than crowding the frame chrome.
|
|
315
|
+
const spaced = rows - result.length - footers.length >= 4;
|
|
316
|
+
if (spaced) { result.splice(1, 0, ""); result.push(""); }
|
|
317
|
+
const capacity = Math.max(0, rows - result.length - footers.length - Number(spaced));
|
|
318
|
+
this.listCapacity = Math.max(1, capacity);
|
|
319
|
+
const maxStart = Math.max(0, items.length - capacity);
|
|
320
|
+
this.listStart = Math.min(this.listStart, maxStart);
|
|
321
|
+
if (this.selected < this.listStart) this.listStart = this.selected;
|
|
322
|
+
else if (capacity > 0 && this.selected >= this.listStart + capacity) this.listStart = this.selected - capacity + 1;
|
|
323
|
+
for (let i = this.listStart; i < Math.min(items.length, this.listStart + capacity); i++) {
|
|
324
|
+
const entry = items[i]!;
|
|
325
|
+
const marker = entry.source ? " [source]" : "";
|
|
326
|
+
const line = `${i === this.selected ? "▸ " : " "}${oneLine(entry.title)}`;
|
|
327
|
+
const rendered = i === this.selected ? `${accent(line)}${marker ? dim(marker) : ""}` : `${fit(line)}${marker ? dim(marker) : ""}`;
|
|
328
|
+
result.push(truncateToWidth(rendered, safeWidth));
|
|
329
|
+
}
|
|
330
|
+
if (spaced) result.push("");
|
|
331
|
+
result.push(...footers);
|
|
332
|
+
} else {
|
|
333
|
+
let breadcrumb: string;
|
|
334
|
+
if (this.view === "help") breadcrumb = `Memory inspector › ${TAB_LABELS[this.tab]} › Help`;
|
|
335
|
+
else {
|
|
336
|
+
const prefix = `Memory inspector › ${TAB_LABELS[this.tab]} › `;
|
|
337
|
+
const suffix = this.view === "source" ? " › Source" : "";
|
|
338
|
+
const titleWidth = Math.max(1, safeWidth - visibleWidth(prefix) - visibleWidth(suffix));
|
|
339
|
+
breadcrumb = `${prefix}${truncateToWidth(oneLine(this.item?.title ?? "Detail"), titleWidth, "…")}${suffix}`;
|
|
340
|
+
}
|
|
341
|
+
result.push(accent(t.bold(breadcrumb)));
|
|
342
|
+
let body: string;
|
|
343
|
+
const missingSource = this.view === "detail" && !this.item?.source;
|
|
344
|
+
if (this.view === "help") {
|
|
345
|
+
const actions = this.tab === "memories" && this.options.onAction ? "a runs the explicit memory action (closes this view first)." : "No explicit action is available in this view.";
|
|
346
|
+
const helpItem = this.helpReturn === "list" ? selected : this.item;
|
|
347
|
+
const sourceHelp = helpItem?.source ? `s opens the linked source text; ${key("tui.select.cancel")} returns to the view that opened it.` : "Source text is read-only; it is shown only when linked to a record.";
|
|
348
|
+
body = [
|
|
349
|
+
"Navigation: In the list, Tab / Shift+Tab switch tabs; switching tabs clears the search query. ← / → changes memory scope in the Memories list only.",
|
|
350
|
+
`${key("tui.select.up")} / ${key("tui.select.down")} moves selection within a list; ${key("tui.select.confirm")} opens the selected record. In detail/source/help, the arrow keys scroll the current text instead.`,
|
|
351
|
+
"n / p moves to the next / previous result page only when available. / starts search in Memories and Timeline; Context has no search.",
|
|
352
|
+
`${sourceHelp} ${actions}`,
|
|
353
|
+
"Records and linked sources are read-only here. A linked source is a reference, not independent verification. Explicit actions are separate from reading; the cancel key goes back, F10 closes.",
|
|
354
|
+
"Scope names: Session is session-only; Working is API project (working memory); Project is API project-long; Persona and Shared are wider durable scopes.",
|
|
355
|
+
this.page?.notice || "No additional coverage notice.",
|
|
356
|
+
].join("\n\n");
|
|
357
|
+
} else if (this.view === "source") body = this.item?.source?.body ?? "";
|
|
358
|
+
else body = this.item?.body ?? "";
|
|
359
|
+
let wrapped: string[];
|
|
360
|
+
if (this.wrappedCache?.width === safeWidth && this.wrappedCache.body === body) wrapped = this.wrappedCache.lines;
|
|
361
|
+
else {
|
|
362
|
+
wrapped = wrapTextWithAnsi(sanitizeCardText(body), safeWidth);
|
|
363
|
+
// Width changes reflow text: retain the first visible text, not its old wrapped-row index.
|
|
364
|
+
if (this.wrappedCache?.body === body) {
|
|
365
|
+
const previousScroll = this.view === "source" ? this.sourceScroll : this.view === "help" ? this.helpScroll : this.detailScroll;
|
|
366
|
+
const length = (line: string) => line.replace(/\s/g, "").length;
|
|
367
|
+
const offset = this.wrappedCache.lines.slice(0, previousScroll).reduce((total, line) => total + length(line), 0);
|
|
368
|
+
let consumed = 0;
|
|
369
|
+
let mapped = 0;
|
|
370
|
+
while (mapped < wrapped.length - 1 && consumed + length(wrapped[mapped]!) <= offset) consumed += length(wrapped[mapped++]!);
|
|
371
|
+
this.setDetailScroll(mapped);
|
|
372
|
+
}
|
|
373
|
+
this.wrappedCache = { width: safeWidth, body, lines: wrapped };
|
|
374
|
+
}
|
|
375
|
+
const displayWrapped = [...wrapped];
|
|
376
|
+
const missingSourceIndex = missingSource ? displayWrapped.push("", "Source unavailable for this item.") - 1 : -1;
|
|
377
|
+
const actions = this.view === "detail" && this.tab === "memories" && this.options.onAction ? ["a actions"] : [];
|
|
378
|
+
const pageKeys = `${pair("tui.select.pageUp", "tui.select.pageDown")} page`;
|
|
379
|
+
let footers = safeWidth < 20
|
|
380
|
+
? [dim(`↑↓ scroll/${key("tui.select.cancel")}`)]
|
|
381
|
+
: safeWidth < 32
|
|
382
|
+
? footer([`${pair("tui.select.up", "tui.select.down")} scroll`, `${key("tui.select.cancel")} back`])
|
|
383
|
+
: [
|
|
384
|
+
...footer([`${pair("tui.select.up", "tui.select.down")} scroll`, pageKeys]),
|
|
385
|
+
...footer([...(this.view === "detail" && this.item?.source ? ["s source"] : []), ...actions, `${key("tui.select.cancel")} back`, "F10 close"]),
|
|
386
|
+
];
|
|
387
|
+
const scroll = this.view === "source" ? this.sourceScroll : this.view === "help" ? this.helpScroll : this.detailScroll;
|
|
388
|
+
// Content wins over chrome, including extremely short detail/source/help views.
|
|
389
|
+
if (rows < 3) result.length = 0;
|
|
390
|
+
const indicatorRows = rows >= 5 ? 2 : 0;
|
|
391
|
+
if (rows - result.length - footers.length - indicatorRows < 1) {
|
|
392
|
+
footers = rows - result.length - indicatorRows >= 2 ? [dim(`${key("tui.select.cancel")} back · F10 close`)] : [];
|
|
393
|
+
}
|
|
394
|
+
const spaced = rows - result.length - footers.length - indicatorRows >= 3;
|
|
395
|
+
if (spaced) result.push("");
|
|
396
|
+
const capacity = Math.max(0, rows - result.length - footers.length - indicatorRows - Number(spaced));
|
|
397
|
+
this.detailCapacity = Math.max(1, capacity);
|
|
398
|
+
const maxStart = Math.max(0, displayWrapped.length - capacity);
|
|
399
|
+
const start = Math.min(scroll, maxStart);
|
|
400
|
+
this.setDetailScroll(start);
|
|
401
|
+
if (indicatorRows && start > 0) result.push(dim(`▲ ${start} lines above`));
|
|
402
|
+
result.push(...displayWrapped.slice(start, start + capacity).map((line, index) => start + index === missingSourceIndex ? t.fg("warning", fit(line)) : this.view === "help" ? dim(line) : fit(line)));
|
|
403
|
+
if (indicatorRows && start + capacity < displayWrapped.length) result.push(dim(`▼ ${displayWrapped.length - start - capacity} lines below`));
|
|
404
|
+
if (spaced) result.push("");
|
|
405
|
+
result.push(...footers);
|
|
406
|
+
}
|
|
407
|
+
return result.slice(0, rows).map(fit);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
takeAction(): (InspectorRequest & { selectedId?: string }) | undefined {
|
|
411
|
+
const action = this.pendingAction;
|
|
412
|
+
this.pendingAction = undefined;
|
|
413
|
+
return action;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
invalidate(): void {}
|
|
417
|
+
dispose(): void { this.options.signal?.removeEventListener("abort", this.onAbort); this.closed = true; this.generation++; }
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export function createMemoryInspectorComponent(
|
|
421
|
+
tui: TUI,
|
|
422
|
+
theme: { fg(name: "accent" | "border" | "dim" | "warning" | "error" | "success", text: string): string; bold(text: string): string },
|
|
423
|
+
keybindings: KeybindingsManager,
|
|
424
|
+
done: (result: void) => void,
|
|
425
|
+
options: MemoryInspectorOptions,
|
|
426
|
+
): MemoryInspectorComponent {
|
|
427
|
+
return new MemoryInspectorComponent(tui, theme, keybindings, done, options);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export async function openMemoryInspector(
|
|
431
|
+
ctx: ExtensionContext,
|
|
432
|
+
options: MemoryInspectorOptions,
|
|
433
|
+
): Promise<void> {
|
|
434
|
+
if (ctx.mode !== "tui") { ctx.ui.notify("Memory inspector requires interactive mode", "warning"); return; }
|
|
435
|
+
if (options.signal?.aborted || !options.isCurrent()) return;
|
|
436
|
+
const frame = options.frame;
|
|
437
|
+
if (!frame) { ctx.ui.notify("Memory inspector unavailable: reload a compatible pi-persona extension.", "warning"); return; }
|
|
438
|
+
try {
|
|
439
|
+
let overlayTui: TUI | undefined;
|
|
440
|
+
let component: MemoryInspectorComponent | undefined;
|
|
441
|
+
await ctx.ui.custom<void>((tui, theme, keybindings, done) => {
|
|
442
|
+
overlayTui = tui;
|
|
443
|
+
component = new MemoryInspectorComponent(tui, theme, keybindings, done, {
|
|
444
|
+
...options,
|
|
445
|
+
viewportHeight: () => frame.viewportRows(tui.terminal?.rows ?? 1),
|
|
446
|
+
});
|
|
447
|
+
return component;
|
|
448
|
+
}, {
|
|
449
|
+
overlay: true,
|
|
450
|
+
overlayOptions: () => {
|
|
451
|
+
const rows = overlayTui?.terminal?.rows ?? 1;
|
|
452
|
+
return { width: "90%", maxHeight: frame.viewportRows(rows), margin: 1 };
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
const action = component?.takeAction();
|
|
456
|
+
if (action && !options.signal?.aborted && options.isCurrent() && options.onAction) await options.onAction(action);
|
|
457
|
+
} catch (error) {
|
|
458
|
+
if (!options.signal?.aborted && options.isCurrent()) ctx.ui.notify(`Memory inspector closed: ${error instanceof Error ? error.message : "unknown error"}`, "warning");
|
|
459
|
+
}
|
|
460
|
+
}
|