@howaboua/pi-notes-compaction 0.0.9 → 0.0.11

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +28 -5
  2. package/PCC-INTEGRATION.md +7 -98
  3. package/README.md +21 -13
  4. package/package.json +7 -3
  5. package/src/activation.ts +152 -0
  6. package/src/agent-identity.ts +119 -0
  7. package/src/attachment-snapshot.ts +103 -0
  8. package/src/binding-startup.ts +30 -0
  9. package/src/bridge.ts +1 -43
  10. package/src/compaction-projection.ts +88 -0
  11. package/src/context-owner.ts +103 -0
  12. package/src/context-sharing.ts +144 -0
  13. package/src/extension-hooks.ts +198 -0
  14. package/src/extension-sharing.ts +118 -0
  15. package/src/fresh-checkpoint.ts +117 -0
  16. package/src/fresh-notes.ts +141 -26
  17. package/src/history-search-protocol.ts +39 -0
  18. package/src/history-search-pruning.mjs +120 -0
  19. package/src/history-search-worker.mjs +258 -0
  20. package/src/history-search.ts +269 -0
  21. package/src/history.ts +212 -40
  22. package/src/idle-admission.ts +201 -0
  23. package/src/index.ts +71 -401
  24. package/src/integrations.ts +159 -0
  25. package/src/lifecycle.ts +63 -448
  26. package/src/note-save-marker.ts +112 -0
  27. package/src/notes-lookup.ts +112 -0
  28. package/src/notes.ts +24 -28
  29. package/src/query-executor.ts +190 -0
  30. package/src/remote.ts +357 -0
  31. package/src/rollover.ts +212 -0
  32. package/src/saved-session.ts +44 -7
  33. package/src/session-pruning-content.ts +237 -0
  34. package/src/session-pruning-plan.ts +243 -0
  35. package/src/session-pruning-policy.ts +20 -0
  36. package/src/session-pruning-screen.ts +204 -0
  37. package/src/session-pruning-source.ts +44 -0
  38. package/src/session-pruning-transaction.ts +141 -0
  39. package/src/session-pruning.ts +155 -0
  40. package/src/settings-command.ts +77 -0
  41. package/src/settings-screen.ts +84 -19
  42. package/src/settings.ts +143 -11
  43. package/src/shared-notes.ts +37 -14
  44. package/src/sharing-service.ts +348 -0
  45. package/src/sqlite.mjs +33 -0
  46. package/src/store.ts +46 -13
  47. package/src/task-boundary.ts +6 -1
  48. package/src/tool-contracts.ts +279 -0
  49. package/src/tools.ts +19 -560
  50. package/src/tree-archive.ts +149 -0
  51. package/src/tree-checkpoint.ts +170 -0
  52. package/src/tree-handoff-read.ts +192 -0
  53. package/src/window-checkpoint.ts +105 -0
  54. package/src/windows.ts +25 -9
@@ -0,0 +1,44 @@
1
+ import { createReadStream } from "node:fs";
2
+ import { createInterface } from "node:readline";
3
+ import type {
4
+ SessionEntry,
5
+ SessionHeader,
6
+ } from "@earendil-works/pi-coding-agent";
7
+
8
+ export type PruningRecord = SessionEntry | SessionHeader;
9
+
10
+ /** Read a finite complete-line prefix, with at most one JSON record buffered. */
11
+ export async function scanSession(
12
+ path: string,
13
+ end: number,
14
+ visit: (entry: PruningRecord, raw: string) => void | Promise<void>,
15
+ ): Promise<void> {
16
+ if (end <= 0) throw new Error("Session has not been saved yet.");
17
+ const stream = createReadStream(path, {
18
+ start: 0,
19
+ end: end - 1,
20
+ highWaterMark: 64 * 1024,
21
+ });
22
+ const lines = createInterface({ input: stream, crlfDelay: Infinity });
23
+ try {
24
+ for await (const line of lines) {
25
+ if (!line) throw new Error("Session contains an empty record.");
26
+ const entry: PruningRecord = JSON.parse(line);
27
+ if (
28
+ !entry ||
29
+ typeof entry !== "object" ||
30
+ typeof entry.type !== "string" ||
31
+ typeof entry.id !== "string" ||
32
+ typeof entry.timestamp !== "string" ||
33
+ (entry.type !== "session" &&
34
+ entry.parentId !== null &&
35
+ typeof entry.parentId !== "string")
36
+ )
37
+ throw new Error("Session contains an invalid record.");
38
+ await visit(entry, line);
39
+ }
40
+ } finally {
41
+ lines.close();
42
+ stream.destroy();
43
+ }
44
+ }
@@ -0,0 +1,141 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import {
3
+ closeSync,
4
+ fsyncSync,
5
+ lstatSync,
6
+ openSync,
7
+ readSync,
8
+ renameSync,
9
+ type Stats,
10
+ statSync,
11
+ unlinkSync,
12
+ writeFileSync,
13
+ } from "node:fs";
14
+ import { open } from "node:fs/promises";
15
+ import type {
16
+ ExtensionAPI,
17
+ ExtensionContext,
18
+ } from "@earendil-works/pi-coding-agent";
19
+ import type { PruningPlan } from "./session-pruning-plan.js";
20
+ import {
21
+ pruningContext,
22
+ transformPruningEntry,
23
+ } from "./session-pruning-plan.js";
24
+ import { scanSession } from "./session-pruning-source.js";
25
+
26
+ const MAX_COMMIT_TAIL = 4 * 1024 * 1024;
27
+
28
+ function sameSource(plan: PruningPlan): Stats {
29
+ const current = lstatSync(plan.path);
30
+ if (
31
+ !current.isFile() ||
32
+ current.dev !== plan.source.dev ||
33
+ current.ino !== plan.source.ino ||
34
+ current.size < plan.source.size ||
35
+ (current.size === plan.source.size &&
36
+ current.mtimeMs !== plan.source.mtimeMs)
37
+ )
38
+ throw new Error(
39
+ "Session changed while pruning was prepared. Run now again.",
40
+ );
41
+ return current;
42
+ }
43
+
44
+ /** SDK writes to this already-flushed path are synchronous appends. No await from
45
+ * final identity check through rename: extension/monitor appends cannot interleave.
46
+ * Fork writes a different path; migration rewrites happen before session_start.
47
+ */
48
+ export async function commitSessionPruning(
49
+ pi: Pick<ExtensionAPI, "appendEntry">,
50
+ ctx: Pick<ExtensionContext, "sessionManager">,
51
+ plan: PruningPlan,
52
+ checkPolicy: () => void = () => {},
53
+ ): Promise<{ before: number; after: number }> {
54
+ const valid = () => {
55
+ checkPolicy();
56
+ if (
57
+ ctx.sessionManager.getSessionId() !== plan.sessionId ||
58
+ ctx.sessionManager.getSessionFile() !== plan.path
59
+ )
60
+ throw new Error("Active session changed. Run now again.");
61
+ for (const id of pruningContext(ctx.sessionManager).protectedIds)
62
+ if (plan.ids.has(id) && !plan.protectedIds.has(id))
63
+ throw new Error("Active context changed. Run now again.");
64
+ return sameSource(plan);
65
+ };
66
+ valid();
67
+ const generation = randomUUID();
68
+ pi.appendEntry("notes-session-prune", {
69
+ version: 1,
70
+ sessionId: plan.sessionId,
71
+ generation,
72
+ });
73
+ const temp = `${plan.path}.prune-${generation}.tmp`;
74
+ let output: Awaited<ReturnType<typeof open>> | undefined;
75
+ try {
76
+ output = await open(temp, "wx", plan.source.mode & 0o777);
77
+ const file = output;
78
+ await scanSession(plan.path, plan.source.size, async (entry, raw) => {
79
+ const transformed =
80
+ entry.type === "session"
81
+ ? {
82
+ ...entry,
83
+ notesPruning: {
84
+ version: 1,
85
+ sessionId: plan.sessionId,
86
+ generation,
87
+ },
88
+ }
89
+ : transformPruningEntry(plan, entry);
90
+ await file.writeFile(
91
+ `${transformed === entry ? raw : JSON.stringify(transformed)}\n`,
92
+ );
93
+ });
94
+ await file.sync();
95
+ await file.close();
96
+ output = undefined;
97
+ // Bounded synchronous commit includes every append since the preview prefix.
98
+ const current = valid();
99
+ const length = current.size - plan.source.size;
100
+ if (length > MAX_COMMIT_TAIL)
101
+ throw new Error("Session grew too much during pruning. Run now again.");
102
+ const input = openSync(plan.path, "r");
103
+ let tail: Buffer;
104
+ try {
105
+ tail = Buffer.alloc(length);
106
+ let offset = 0;
107
+ while (offset < length) {
108
+ const read = readSync(
109
+ input,
110
+ tail,
111
+ offset,
112
+ length - offset,
113
+ plan.source.size + offset,
114
+ );
115
+ if (!read) throw new Error("Session changed during pruning.");
116
+ offset += read;
117
+ }
118
+ } finally {
119
+ closeSync(input);
120
+ }
121
+ if (tail.length && tail.at(-1) !== 10)
122
+ throw new Error("Session has an incomplete append. Run now again.");
123
+ const fd = openSync(temp, "a");
124
+ try {
125
+ if (tail.length) writeFileSync(fd, tail);
126
+ fsyncSync(fd);
127
+ } finally {
128
+ closeSync(fd);
129
+ }
130
+ const after = statSync(temp).size;
131
+ renameSync(temp, plan.path);
132
+ return { before: current.size, after };
133
+ } finally {
134
+ await output?.close();
135
+ try {
136
+ unlinkSync(temp);
137
+ } catch (error) {
138
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
139
+ }
140
+ }
141
+ }
@@ -0,0 +1,155 @@
1
+ import type {
2
+ ExtensionAPI,
3
+ ExtensionContext,
4
+ } from "@earendil-works/pi-coding-agent";
5
+ import type { HistorySearch } from "./history-search.js";
6
+ import { planSessionPruning } from "./session-pruning-plan.js";
7
+ import { RESTART_NOTICE } from "./session-pruning-policy.js";
8
+ import { commitSessionPruning } from "./session-pruning-transaction.js";
9
+ import type { NotesStore } from "./store.js";
10
+ import { windowDetails } from "./windows.js";
11
+
12
+ const bytes = (value: number) => `${(value / 1024 / 1024).toFixed(1)} MiB`;
13
+
14
+ export interface SessionPruningInteraction {
15
+ progress: (message: string) => void;
16
+ confirm: (title: string, message: string) => Promise<boolean>;
17
+ }
18
+
19
+ export class SessionPruning {
20
+ private running = false;
21
+ private observed: string | undefined;
22
+ private pending: string | undefined;
23
+ private epoch = 0;
24
+ private readonly pi: ExtensionAPI;
25
+ private readonly store: NotesStore;
26
+ private readonly search: HistorySearch;
27
+ private readonly admittedWindow: () => string | undefined;
28
+ constructor(
29
+ pi: ExtensionAPI,
30
+ store: NotesStore,
31
+ search: HistorySearch,
32
+ admittedWindow: () => string | undefined,
33
+ ) {
34
+ this.pi = pi;
35
+ this.store = store;
36
+ this.search = search;
37
+ this.admittedWindow = admittedWindow;
38
+ }
39
+
40
+ private persistedWindow(ctx: ExtensionContext): string | undefined {
41
+ for (const entry of ctx.sessionManager.getBranch().reverse()) {
42
+ const details = windowDetails(entry);
43
+ if (details?.kind === "window")
44
+ return `${ctx.sessionManager.getSessionId()}:${details.identity.currentWindowId}`;
45
+ }
46
+ }
47
+ register(): void {
48
+ this.pi.on("session_start", (_event, ctx) => {
49
+ this.epoch++;
50
+ this.observed = this.persistedWindow(ctx);
51
+ this.pending = undefined;
52
+ });
53
+ this.pi.on("session_shutdown", () => {
54
+ this.epoch++;
55
+ this.pending = undefined;
56
+ });
57
+ this.pi.on("agent_start", (_event, ctx) => {
58
+ // Pi emits agent_start before persisting incoming messages. Notes already
59
+ // admitted the successor in before_agent_start; confirm its commit below.
60
+ const window = this.admittedWindow();
61
+ const current = window
62
+ ? `${ctx.sessionManager.getSessionId()}:${window}`
63
+ : undefined;
64
+ if (current && current !== this.observed) this.pending = current;
65
+ this.observed = current;
66
+ });
67
+ // The successor marker and complete turn_end checkpoint are now committed.
68
+ // Ordinary turns without a new-window admission do no pruning work.
69
+ this.pi.on("agent_settled", async (_event, ctx) => {
70
+ if (!this.pending) return;
71
+ const pending = this.pending;
72
+ this.pending = undefined;
73
+ if (pending === this.persistedWindow(ctx)) await this.run(ctx, false);
74
+ });
75
+ }
76
+
77
+ async run(
78
+ ctx: ExtensionContext,
79
+ manual: boolean,
80
+ interaction?: SessionPruningInteraction,
81
+ ): Promise<void> {
82
+ if (this.running) {
83
+ if (manual) ctx.ui.notify("Session pruning is already running.", "info");
84
+ return;
85
+ }
86
+ this.running = true;
87
+ const epoch = this.epoch;
88
+ let historyPruned = false;
89
+ try {
90
+ const policy = this.store.pruningPolicy(
91
+ ctx.sessionManager.getSessionId(),
92
+ );
93
+ if (!policy.windows && !policy.days) {
94
+ if (manual)
95
+ ctx.ui.notify(
96
+ "Session pruning is off. Choose a history or conversation limit first.",
97
+ "info",
98
+ );
99
+ return;
100
+ }
101
+ interaction?.progress("Preparing pruning preview…");
102
+ const plan = await planSessionPruning(ctx.sessionManager, policy);
103
+ if (!plan.changed) {
104
+ interaction?.progress("Cleaning ranked history…");
105
+ await this.search.pruneSession(plan.sessionId, plan.path);
106
+ if (manual)
107
+ ctx.ui.notify(
108
+ "Nothing to prune under this session's limits.",
109
+ "info",
110
+ );
111
+ return;
112
+ }
113
+ if (
114
+ manual &&
115
+ !(await (interaction?.confirm ?? ctx.ui.confirm)(
116
+ "Prune this session's history?",
117
+ `${bytes(plan.before)} → about ${bytes(plan.after)}; ${plan.changed} records changed. Current context and saved SQLite notes are protected. Older tool activity, injected instructions and exact execution replay are permanently lost. No backup is kept.${plan.opaque.length ? ` Opaque extension state is retained: ${plan.opaque.join(", ")}.` : ""} ${RESTART_NOTICE}`,
118
+ ))
119
+ )
120
+ return;
121
+ const currentPolicy = this.store.pruningPolicy(plan.sessionId);
122
+ if (
123
+ currentPolicy.windows !== policy.windows ||
124
+ currentPolicy.days !== policy.days
125
+ )
126
+ throw new Error("Session pruning settings changed. Run now again.");
127
+ interaction?.progress("Pruning session history…");
128
+ const result = await commitSessionPruning(this.pi, ctx, plan, () => {
129
+ if (this.epoch !== epoch)
130
+ throw new Error(
131
+ "Session changed while pruning was prepared. Run now again.",
132
+ );
133
+ const current = this.store.pruningPolicy(plan.sessionId);
134
+ if (current.windows !== policy.windows || current.days !== policy.days)
135
+ throw new Error("Session pruning settings changed. Run now again.");
136
+ });
137
+ historyPruned = true;
138
+ interaction?.progress("Cleaning ranked history…");
139
+ await this.search.pruneSession(plan.sessionId, plan.path);
140
+ ctx.ui.notify(
141
+ `Pruned session history: ${bytes(result.before)} → ${bytes(result.after)}. Saved notes unchanged. ${RESTART_NOTICE}`,
142
+ "info",
143
+ );
144
+ } catch (error) {
145
+ ctx.ui.notify(
146
+ historyPruned
147
+ ? `Session history was pruned, but ranked history cleanup did not complete. Run now again to retry cleanup. ${RESTART_NOTICE}`
148
+ : `Session pruning did not complete: ${error instanceof Error ? error.message : String(error)}`,
149
+ "error",
150
+ );
151
+ } finally {
152
+ this.running = false;
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,77 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { NotesActivation } from "./activation.js";
3
+ import type { HistorySearch } from "./history-search.js";
4
+ import type { NotesLifecycle } from "./lifecycle.js";
5
+ import { sessionRef } from "./notes.js";
6
+ import type { SessionPruning } from "./session-pruning.js";
7
+ import type { NotesSettings } from "./settings.js";
8
+ import { openNotesSettings } from "./settings-screen.js";
9
+ import type { NotesStore } from "./store.js";
10
+
11
+ export function registerNotesSettingsCommand(
12
+ pi: ExtensionAPI,
13
+ activation: NotesActivation,
14
+ lifecycle: NotesLifecycle,
15
+ store: NotesStore,
16
+ search: HistorySearch,
17
+ settingsPath: string,
18
+ sessionPruning: SessionPruning,
19
+ ): void {
20
+ pi.registerCommand("notes", {
21
+ description: "Manage local notes and context rollover",
22
+ handler: async (args, ctx) => {
23
+ if (args.trim()) {
24
+ ctx.ui.notify("Use /notes to open settings.", "info");
25
+ return;
26
+ }
27
+ if (!ctx.hasUI) {
28
+ ctx.ui.notify("Notes settings require interactive Pi.", "warning");
29
+ return;
30
+ }
31
+ const save = (value: NotesSettings) => activation.save(value, ctx);
32
+ const prune = async () => {
33
+ await ctx.waitForIdle();
34
+ store.updateFile(sessionRef(ctx));
35
+ const sources = store.sessionFiles();
36
+ const result = store.prune(ctx.sessionManager.getSessionId());
37
+ const indexed = await search.prune(
38
+ ctx.sessionManager.getSessionId(),
39
+ sources,
40
+ );
41
+ ctx.ui.notify(
42
+ `Pruned ${result.removed} Notes sessions and ${indexed.removed} indexed sessions. Retained ${result.unknownPaths + indexed.unknownPaths} unknown paths and ${result.inaccessible + indexed.inaccessible} inaccessible files.${indexed.storageBusy ? " Index storage cleanup is pending; run Prune again when other agents are idle." : ""}`,
43
+ "info",
44
+ );
45
+ };
46
+ try {
47
+ await openNotesSettings(ctx, {
48
+ settings: () => activation.settings,
49
+ save,
50
+ settingsPath,
51
+ prune,
52
+ sessionPruning: {
53
+ get: () => store.pruningPolicy(ctx.sessionManager.getSessionId()),
54
+ save: (value) =>
55
+ store.setPruningPolicy(ctx.sessionManager.getSessionId(), value),
56
+ run: async (interaction) => {
57
+ await ctx.waitForIdle();
58
+ await sessionPruning.run(ctx, true, interaction);
59
+ },
60
+ },
61
+ status: () => {
62
+ const counts = store.status();
63
+ return [
64
+ lifecycle.active
65
+ ? "Continuity active"
66
+ : `Continuity inactive: ${activation.unavailable ?? (activation.ready ? "model not in whitelist" : "not initialized")}`,
67
+ `${counts.sessions} sessions · ${counts.revisions} note revisions · ${counts.cachedResponses} cached responses`,
68
+ `Hybrid lookup: ${lifecycle.bridge?.lookup ? "available" : "unavailable"} · Encrypted delivery: ${lifecycle.bridge?.projectResult ? "available" : "unavailable"}`,
69
+ ];
70
+ },
71
+ });
72
+ } catch (error) {
73
+ ctx.ui.notify(`Notes settings failed: ${String(error)}`, "error");
74
+ }
75
+ },
76
+ });
77
+ }
@@ -7,6 +7,10 @@ import {
7
7
  truncateToWidth,
8
8
  wrapTextWithAnsi,
9
9
  } from "@earendil-works/pi-tui";
10
+ import {
11
+ openSessionPruningSettings,
12
+ type SessionPruningSettings,
13
+ } from "./session-pruning-screen.js";
10
14
  import {
11
15
  IDLE_MINUTES,
12
16
  NEW_WINDOW_REQUESTS,
@@ -22,10 +26,11 @@ export async function openNotesSettings(
22
26
  save: (settings: NotesSettings) => void;
23
27
  status: () => string[];
24
28
  prune: () => Promise<void>;
29
+ sessionPruning: SessionPruningSettings;
25
30
  },
26
31
  ): Promise<void> {
27
32
  while (true) {
28
- const action = await ctx.ui.custom<"close" | "prune">(
33
+ const action = await ctx.ui.custom<"close" | "prune" | "sessionPruning">(
29
34
  (tui, theme, _kb, done) => {
30
35
  const settings = options.settings();
31
36
  const idleValue = (minutes: number) =>
@@ -36,6 +41,14 @@ export async function openNotesSettings(
36
41
  : `${Math.ceil(minutes / 60)}h`;
37
42
  const list = new SettingsList(
38
43
  [
44
+ {
45
+ id: "sessionPruning",
46
+ label: "Session auto-pruning",
47
+ currentValue: "select…",
48
+ values: ["select…", "settings…"],
49
+ description:
50
+ "Per-session history limits and Run now. Memory savings require restarting Pi.",
51
+ },
39
52
  {
40
53
  id: "active",
41
54
  label: "Active",
@@ -44,6 +57,28 @@ export async function openNotesSettings(
44
57
  settings.active === "all" ? "All models" : "Whitelist",
45
58
  values: ["All models", "Whitelist"],
46
59
  },
60
+ {
61
+ id: "sharing",
62
+ label: "Share subagent context",
63
+ description:
64
+ "Let new child agents share notes and history. Existing families remain connected when off.",
65
+ currentValue: settings.shareSubagentContext ? "on" : "off",
66
+ values: ["off", "on"],
67
+ },
68
+ {
69
+ id: "rankedHistorySearch",
70
+ label: "Ranked history search",
71
+ description:
72
+ "BM25 for earlier user messages and assistant replies. Skips current context and tool activity.",
73
+ currentValue: settings.rankedHistorySearch ? "on" : "off",
74
+ values: ["off", "on"],
75
+ },
76
+ {
77
+ id: "noteSaveMarkers",
78
+ label: "Note-save markers",
79
+ currentValue: settings.noteSaveMarkers ? "on" : "off",
80
+ values: ["off", "on"],
81
+ },
47
82
  {
48
83
  id: "compact",
49
84
  label: "Normal compaction",
@@ -83,7 +118,7 @@ export async function openNotesSettings(
83
118
  id: "prune",
84
119
  label: "Prune missing sessions",
85
120
  description:
86
- "Remove stored records only for missing session files. Keeps active sessions, unknown paths and inaccessible files. Confirmation required.",
121
+ "Remove notes, cached responses and history index entries for missing session files. Keeps the active session, unknown paths and inaccessible files. Confirmation required.",
87
122
  currentValue: "select…",
88
123
  values: ["select…", "prune…"],
89
124
  },
@@ -91,6 +126,10 @@ export async function openNotesSettings(
91
126
  5,
92
127
  getSettingsListTheme(),
93
128
  (id, value) => {
129
+ if (id === "sessionPruning") {
130
+ done("sessionPruning");
131
+ return;
132
+ }
94
133
  if (id === "prune") {
95
134
  done("prune");
96
135
  return;
@@ -116,6 +155,18 @@ export async function openNotesSettings(
116
155
  ...current,
117
156
  active: value === "All models" ? "all" : "whitelist",
118
157
  });
158
+ else if (id === "sharing")
159
+ options.save({
160
+ ...current,
161
+ shareSubagentContext: value === "on",
162
+ });
163
+ else if (id === "noteSaveMarkers")
164
+ options.save({ ...current, noteSaveMarkers: value === "on" });
165
+ else if (id === "rankedHistorySearch")
166
+ options.save({
167
+ ...current,
168
+ rankedHistorySearch: value === "on",
169
+ });
119
170
  else if (id === "compact")
120
171
  options.save({ ...current, normalCompaction: value === "on" });
121
172
  else if (id === "newWindowRequests") {
@@ -140,22 +191,32 @@ export async function openNotesSettings(
140
191
  options.save({ ...current, idleMinutes });
141
192
  }
142
193
  } catch (error) {
143
- list.updateValue(
144
- id,
145
- id === "active"
146
- ? current.active === "all"
147
- ? "All models"
148
- : "Whitelist"
149
- : id === "taskBoundaryReminder"
150
- ? taskBoundaryLabel(current.taskBoundaryReminder)
151
- : id === "newWindowRequests"
152
- ? current.newWindowRequests
153
- : id === "compact"
154
- ? current.normalCompaction
155
- ? "on"
156
- : "off"
157
- : idleValue(current.idleMinutes),
158
- );
194
+ if (id === "rankedHistorySearch") {
195
+ list.updateValue(
196
+ id,
197
+ current.rankedHistorySearch ? "on" : "off",
198
+ );
199
+ } else
200
+ list.updateValue(
201
+ id,
202
+ id === "active"
203
+ ? current.active === "all"
204
+ ? "All models"
205
+ : "Whitelist"
206
+ : id === "taskBoundaryReminder"
207
+ ? taskBoundaryLabel(current.taskBoundaryReminder)
208
+ : id === "newWindowRequests"
209
+ ? current.newWindowRequests
210
+ : id === "noteSaveMarkers"
211
+ ? current.noteSaveMarkers
212
+ ? "on"
213
+ : "off"
214
+ : id === "compact"
215
+ ? current.normalCompaction
216
+ ? "on"
217
+ : "off"
218
+ : idleValue(current.idleMinutes),
219
+ );
159
220
  ctx.ui.notify(
160
221
  `Could not save notes settings: ${String(error)}`,
161
222
  "error",
@@ -207,10 +268,14 @@ export async function openNotesSettings(
207
268
  },
208
269
  );
209
270
  if (action === "close") return;
271
+ if (action === "sessionPruning") {
272
+ await openSessionPruningSettings(ctx, options.sessionPruning);
273
+ continue;
274
+ }
210
275
  if (
211
276
  await ctx.ui.confirm(
212
277
  "Prune missing sessions?",
213
- "Delete local notes and cached responses for missing session files? The active session, unknown paths and inaccessible files are retained.",
278
+ "Delete local notes, cached responses and history index entries for missing session files? The active session, unknown paths and inaccessible files are retained.",
214
279
  )
215
280
  )
216
281
  await options.prune();