@mingxy/cerebro 1.7.0 → 1.7.2
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/package.json +1 -1
- package/src/index.ts +3 -2
- package/src/tui.tsx +17 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,8 +32,9 @@ export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
|
|
|
32
32
|
autoStoreSessions.set(sessionId, enabled);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// Bridge for TUI plugin
|
|
36
|
-
(
|
|
35
|
+
// Bridge for TUI plugin: expose the Map directly so TUI can query with its own sessionID
|
|
36
|
+
// (tool sessionId and TUI sessionID may differ in format)
|
|
37
|
+
(globalThis as any).__cerebro_autoStoreMap = autoStoreSessions;
|
|
37
38
|
|
|
38
39
|
function showToast(tui: any, title: string, message?: string, variant: string = "info", duration: number = 5000) {
|
|
39
40
|
if (!tui) return;
|
package/src/tui.tsx
CHANGED
|
@@ -13,24 +13,34 @@ function SidebarContentView(props: {
|
|
|
13
13
|
const [autoStore, setAutoStore] = createSignal(true);
|
|
14
14
|
const theme = () => props.api.theme.current;
|
|
15
15
|
|
|
16
|
+
const readAutoStore = () => (globalThis as any).__cerebro_autoStoreMap?.get(props.sessionID) ?? true;
|
|
17
|
+
|
|
18
|
+
const debugLine = () => {
|
|
19
|
+
const map = (globalThis as any).__cerebro_autoStoreMap;
|
|
20
|
+
const hasMap = map ? "Y" : "N";
|
|
21
|
+
const sid = props.sessionID?.slice(-8) ?? "none";
|
|
22
|
+
const keys = map ? [...map.keys()].map((k: string) => k.slice(-8)).join(",") : "-";
|
|
23
|
+
return `dbg:${hasMap} sid:${sid} [${keys}]`;
|
|
24
|
+
};
|
|
25
|
+
|
|
16
26
|
const unsubscribers = [
|
|
17
27
|
props.api.event.on("session.updated", () => {
|
|
18
|
-
setAutoStore(
|
|
28
|
+
setAutoStore(readAutoStore());
|
|
19
29
|
}),
|
|
20
30
|
props.api.event.on("tui.session.select", (event) => {
|
|
21
31
|
if (event.properties?.sessionID === props.sessionID) {
|
|
22
|
-
setAutoStore(
|
|
32
|
+
setAutoStore(readAutoStore());
|
|
23
33
|
}
|
|
24
34
|
}),
|
|
25
35
|
];
|
|
26
36
|
|
|
27
37
|
createEffect(() => {
|
|
28
38
|
props.sessionID;
|
|
29
|
-
setAutoStore(
|
|
39
|
+
setAutoStore(readAutoStore());
|
|
30
40
|
});
|
|
31
41
|
|
|
32
42
|
const interval = setInterval(() => {
|
|
33
|
-
setAutoStore(
|
|
43
|
+
setAutoStore(readAutoStore());
|
|
34
44
|
}, 2000);
|
|
35
45
|
|
|
36
46
|
onCleanup(() => {
|
|
@@ -54,6 +64,9 @@ function SidebarContentView(props: {
|
|
|
54
64
|
{"Auto-store: " + (autoStore() ? "ON" : "OFF")}
|
|
55
65
|
</text>
|
|
56
66
|
</box>
|
|
67
|
+
<text fg={theme()?.textMuted} wrapMode="none">
|
|
68
|
+
{debugLine()}
|
|
69
|
+
</text>
|
|
57
70
|
</box>
|
|
58
71
|
);
|
|
59
72
|
}
|