feat(FN-3008): notify when model settings fall back to defaults

Merges FN-3008 to add a "fallback-used" notification system: the engine now emits events when AI model fallbacks are triggered, dispatches notifications via ntfy/webhook providers, surfaces a session banner in the dashboard, and exposes a settings toggle to enable or disable these alerts.

Fusion-Task-Id: FN-3008
This commit is contained in:
Fusion
2026-05-02 19:51:05 -07:00
committed by gsxdsm
parent 44a996e769
commit 68f34dd0f7
26 changed files with 357 additions and 41 deletions

View File

@@ -1,6 +1,10 @@
/* === Session Notification Banner === */
.session-notification-banner {
--session-notification-banner-max-height: min(60vh, calc(var(--space-2xl) * 13));
--session-notification-list-max-height: min(48vh, calc(var(--space-2xl) * 9));
--session-notification-touch-size: calc(var(--space-xl) + var(--space-md));
position: sticky;
top: 0;
z-index: 30;
@@ -8,14 +12,14 @@
flex-direction: column;
gap: var(--space-sm);
padding: var(--space-sm) var(--space-lg);
border-bottom: 1px solid var(--border);
border-left: 4px solid var(--triage);
border-bottom: var(--btn-border-width) solid var(--border);
border-left: var(--space-xs) solid var(--triage);
background: var(--surface);
box-sizing: border-box;
max-height: 420px;
max-height: var(--session-notification-banner-max-height);
opacity: 1;
transition: opacity var(--transition-fast), max-height var(--transition-fast);
animation: session-notification-banner-enter 180ms ease-out;
animation: session-notification-banner-enter var(--transition-fast);
}
@keyframes session-notification-banner-enter {
@@ -25,7 +29,7 @@
}
to {
opacity: 1;
max-height: 420px;
max-height: var(--session-notification-banner-max-height);
}
}
@@ -52,14 +56,15 @@
.session-notification-banner__dismiss-all {
display: inline-flex;
align-items: center;
gap: 6px;
border: 1px solid transparent;
gap: var(--space-sm);
min-height: var(--session-notification-touch-size);
border: var(--btn-border-width) solid transparent;
background: transparent;
color: var(--text-muted);
font-size: 12px;
font-size: 0.75rem;
font-weight: 600;
border-radius: var(--radius-sm);
padding: 4px 8px;
padding: var(--space-xs) var(--space-sm);
cursor: pointer;
transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
@@ -70,12 +75,19 @@
border-color: var(--border);
}
.session-notification-banner__dismiss-all:focus-visible,
.session-notification-banner__resume:focus-visible,
.session-notification-banner__dismiss:focus-visible {
outline: none;
box-shadow: var(--focus-ring-strong);
}
.session-notification-banner__list {
display: flex;
flex-direction: column;
gap: 8px;
gap: var(--space-sm);
overflow-y: auto;
max-height: 300px;
max-height: var(--session-notification-list-max-height);
}
.session-notification-banner__item {
@@ -83,16 +95,21 @@
align-items: center;
justify-content: space-between;
gap: var(--space-sm);
padding: 8px 10px;
border: 1px solid var(--border);
padding: var(--space-sm) var(--space-md);
border: var(--btn-border-width) solid var(--border);
border-radius: var(--radius-sm);
background: color-mix(in srgb, var(--triage) 8%, var(--surface));
}
.session-notification-banner__item--error {
border-color: color-mix(in srgb, var(--color-error) 35%, var(--border));
background: var(--status-error-bg, color-mix(in srgb, var(--color-error) 12%, var(--surface)));
}
.session-notification-banner__item-main {
display: flex;
align-items: center;
gap: 8px;
gap: var(--space-sm);
min-width: 0;
flex: 1;
}
@@ -102,13 +119,17 @@
flex-shrink: 0;
}
.session-notification-banner__type-icon--error {
color: var(--color-error);
}
.session-notification-banner__text {
min-width: 0;
}
.session-notification-banner__title {
margin: 0;
font-size: 13px;
font-size: 0.8125rem;
font-weight: 600;
color: var(--text);
white-space: nowrap;
@@ -117,25 +138,26 @@
}
.session-notification-banner__meta {
margin: 2px 0 0;
font-size: 12px;
margin: var(--space-xs) 0 0;
font-size: 0.75rem;
color: var(--text-muted);
}
.session-notification-banner__actions {
display: inline-flex;
align-items: center;
gap: 6px;
gap: var(--space-sm);
}
.session-notification-banner__resume {
border: 1px solid color-mix(in srgb, var(--triage) 60%, var(--border));
min-height: var(--session-notification-touch-size);
border: var(--btn-border-width) solid color-mix(in srgb, var(--triage) 60%, var(--border));
background: transparent;
color: var(--triage);
border-radius: var(--radius-sm);
font-size: 12px;
font-size: 0.75rem;
font-weight: 600;
padding: 4px 10px;
padding: var(--space-xs) var(--space-md);
cursor: pointer;
transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
@@ -145,14 +167,24 @@
border-color: var(--triage);
}
.session-notification-banner__item--error .session-notification-banner__resume {
border-color: color-mix(in srgb, var(--color-error) 60%, var(--border));
color: var(--color-error);
}
.session-notification-banner__item--error .session-notification-banner__resume:hover {
background: color-mix(in srgb, var(--color-error) 14%, transparent);
border-color: var(--color-error);
}
.session-notification-banner__dismiss {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
width: var(--session-notification-touch-size);
height: var(--session-notification-touch-size);
border-radius: var(--radius-sm);
border: 1px solid transparent;
border: var(--btn-border-width) solid transparent;
background: transparent;
color: var(--text-muted);
cursor: pointer;
@@ -168,7 +200,7 @@
@media (max-width: 768px) {
.session-notification-banner {
padding: var(--space-sm) var(--space-md);
gap: 8px;
gap: var(--space-sm);
}
.session-notification-banner__header {

View File

@@ -238,6 +238,7 @@ const DEFAULT_NTFY_EVENTS: NtfyNotificationEvent[] = [
"awaiting-user-review",
"planning-awaiting-input",
"gridlock",
"fallback-used",
];
const NOTIFICATION_EVENT_OPTIONS: Array<{ event: NtfyNotificationEvent; label: string; description: string }> = [
@@ -248,6 +249,7 @@ const NOTIFICATION_EVENT_OPTIONS: Array<{ event: NtfyNotificationEvent; label: s
{ event: "awaiting-user-review", label: "User review needed", description: "When an agent hands off a task for human review (high priority)" },
{ event: "planning-awaiting-input", label: "Planning needs input", description: "When planning mode is waiting for your response to continue" },
{ event: "gridlock", label: "Pipeline gridlocked", description: "When all schedulable todo tasks are blocked and work cannot advance" },
{ event: "fallback-used", label: "Fallback model used (recovered)", description: "When Fusion recovers from a retryable model failure by switching to a fallback model" },
];
/** Well-known experimental feature flags with display labels.

View File

@@ -2416,6 +2416,18 @@ describe("SettingsModal", () => {
expect(screen.getByRole("button", { name: /Test notification/ })).toBeInTheDocument();
});
it("shows fallback-used event option for both providers", async () => {
mockFetchSettings.mockResolvedValueOnce({ ...defaultSettings, ntfyEnabled: true, ntfyTopic: "test-topic" });
renderModal();
await waitForSettingsModalReady();
await openNotificationsSection();
expect(screen.getByLabelText("Fallback model used (recovered)")).toBeInTheDocument();
await userEvent.click(screen.getByLabelText("Webhook notifications"));
expect(screen.getAllByLabelText("Fallback model used (recovered)").length).toBeGreaterThan(0);
});
it("shows webhook fields when webhook provider is enabled", async () => {
renderModal();
await waitForSettingsModalReady();
@@ -2493,9 +2505,11 @@ describe("SettingsModal", () => {
const inReview = screen.getByLabelText("Task completed (in-review)") as HTMLInputElement;
const failed = screen.getByLabelText("Task failed") as HTMLInputElement;
const merged = screen.getByLabelText("Task merged") as HTMLInputElement;
const fallbackUsed = screen.getByLabelText("Fallback model used (recovered)") as HTMLInputElement;
expect(inReview.checked).toBe(true);
expect(failed.checked).toBe(true);
expect(merged.checked).toBe(false);
expect(fallbackUsed.checked).toBe(false);
});
});

View File

@@ -28,7 +28,7 @@ const defaultSettings = {
defaultPresetBySize: {},
ntfyEnabled: false,
ntfyTopic: undefined,
ntfyEvents: ["in-review", "merged", "failed", "awaiting-approval", "awaiting-user-review"],
ntfyEvents: ["in-review", "merged", "failed", "awaiting-approval", "awaiting-user-review", "fallback-used"],
webhookEnabled: false,
webhookUrl: undefined,
webhookFormat: undefined,