Phase 6: add compaction coexistence hint — one-time notify when both compactors run.

Shows ui.notify once when pi-auto-compact is detected while Pi compaction.enabled stays true.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 11:47:27 +07:00
parent 2e6d36a855
commit bf862656ae
3 changed files with 112 additions and 1 deletions
+53
View File
@@ -2,8 +2,10 @@ import { describe, expect, it } from "vitest";
import {
detectAndCachePiAutoCompact,
detectPiAutoCompact,
maybeNotifyCompactionCoexistenceHint,
PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES,
resolveDeliveryMode,
resolvePiDefaultCompactionEnabled,
} from "../src/auto-compact";
import { createDefaultSettings } from "../src/settings";
import { createRuntimeFlags } from "../src/state";
@@ -53,3 +55,54 @@ describe("PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES", () => {
]);
});
});
describe("resolvePiDefaultCompactionEnabled", () => {
it("defaults to enabled when compaction settings are absent", () => {
expect(resolvePiDefaultCompactionEnabled({}, {})).toBe(true);
});
it("lets project override global compaction.enabled", () => {
expect(
resolvePiDefaultCompactionEnabled(
{ compaction: { enabled: true } },
{ compaction: { enabled: false } },
),
).toBe(false);
});
});
describe("maybeNotifyCompactionCoexistenceHint", () => {
it("notifies once when pi-auto-compact and Pi compaction are both active", () => {
const runtime = createRuntimeFlags();
runtime.autoCompactDetected = true;
const notifications: string[] = [];
const ctx = {
hasUI: true,
ui: {
notify: (message: string) => {
notifications.push(message);
},
},
};
maybeNotifyCompactionCoexistenceHint(ctx as never, runtime, true);
maybeNotifyCompactionCoexistenceHint(ctx as never, runtime, true);
expect(notifications).toHaveLength(1);
expect(runtime.compactionCoexistenceHintShown).toBe(true);
});
it("skips notify when pi-auto-compact is not detected", () => {
const runtime = createRuntimeFlags();
const notifications: string[] = [];
const ctx = {
hasUI: true,
ui: { notify: (message: string) => notifications.push(message) },
};
maybeNotifyCompactionCoexistenceHint(ctx as never, runtime, true);
expect(notifications).toHaveLength(0);
expect(runtime.compactionCoexistenceHintShown).toBe(false);
});
});