feat(FN-2000): add memory auto-summarize settings and automation sync

- Add Memory section controls for enabling auto-summarize with threshold and cron schedule inputs
- Wire ProjectEngine to sync auto-summarize automation on startup and when related settings change
- Reuse a single startup settings snapshot when syncing insight extraction and auto-summarize automations
- Add SettingsModal and ProjectEngine tests covering auto-summarize UI persistence and automation re-sync behavior
This commit is contained in:
Fusion
2026-04-17 09:08:26 -07:00
committed by gsxdsm
parent 3a9c56fda3
commit 28accdb085
19 changed files with 1805 additions and 60 deletions

View File

@@ -168,17 +168,28 @@ export class ProjectEngine {
scope: "project", // Project-scoped execution — global schedules run separately
});
const settings = await store.getSettings();
// Sync insight extraction automation on startup
try {
const { syncInsightExtractionAutomation } = await import("@fusion/core");
if (typeof syncInsightExtractionAutomation === "function") {
const settings = await store.getSettings();
await syncInsightExtractionAutomation(this.automationStore, settings);
}
} catch {
// syncInsightExtractionAutomation may not be exported yet
}
// Sync auto-summarize automation on startup
try {
const { syncAutoSummarizeAutomation } = await import("@fusion/core");
if (typeof syncAutoSummarizeAutomation === "function") {
await syncAutoSummarizeAutomation(this.automationStore, settings);
}
} catch {
// syncAutoSummarizeAutomation may not be exported yet
}
this.cronRunner.start();
runtimeLog.log("CronRunner initialized and started");
} catch (err) {
@@ -969,6 +980,40 @@ export class ProjectEngine {
};
store.on("settings:updated", onInsightSettingsChange);
this.settingsHandlers.push(onInsightSettingsChange);
// 6. Auto-summarize settings change — sync automation
const onAutoSummarizeSettingsChange = async ({
settings: s,
previous: prev,
}: {
settings: Settings;
previous: Settings;
}) => {
const autoSummarizeKeys = [
"memoryAutoSummarizeEnabled",
"memoryAutoSummarizeThresholdChars",
"memoryAutoSummarizeSchedule",
] as const;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const changed = autoSummarizeKeys.some((key) => (s as any)[key] !== (prev as any)[key]);
if (!changed || !this.automationStore) return;
try {
const { syncAutoSummarizeAutomation } = await import("@fusion/core");
if (typeof syncAutoSummarizeAutomation === "function") {
await syncAutoSummarizeAutomation(this.automationStore, s);
runtimeLog.log("Auto-summarize automation synced with settings");
}
} catch (err) {
runtimeLog.warn(
"Failed to sync auto-summarize automation:",
err instanceof Error ? err.message : err,
);
}
};
store.on("settings:updated", onAutoSummarizeSettingsChange);
this.settingsHandlers.push(onAutoSummarizeSettingsChange);
}
/**