feat(usage): PowerUse-Zeitfenster + Handoff-Schwellwert als Settings
Drei neue app_settings-Spalten (Migration AddPowerUseWindow): power_use_window_start/end (HH:mm, lokal, nullable) und power_use_handoff_pct (NOT NULL DEFAULT 95, geclampt 50-99). Die Fensterlogik liegt als reine Funktion in PowerUseWindow (Contains/Normalize/IsOpen): beide Grenzen leer oder nur eine gesetzt = rund um die Uhr, Ende vor Start wrappt ueber Mitternacht, Grenzen halboffen. Geprueft wird in ComposeHandlerPromptAsync, also pro Phase zum Zeitpunkt des Prompt-Baus - die Uhr ist per Func<DateTime> injizierbar. Bedienung im Usage-Monitor neben dem PowerUse-Toggle (Commit auf Blur/Enter, ein Write fuer alle vier Felder); in Settings->General unsichtbar, aber load->save durchgereicht. Nebenbefund, gleicher Pfad: AppSettingsRepository.UpdateAsync kopiert Feld fuer Feld und hat ModelPresets, PowerUseEnabled und ListHandlerMaxHandoffs nie geschrieben - jeder Save dieser drei war still wirkungslos. Mit ergaenzt und per Round-trip-Test gepinnt.
This commit is contained in:
@@ -323,7 +323,10 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
|
||||
row.UsageThrottleSevenDayHardPct,
|
||||
row.AutoContinueOnUsageLimit,
|
||||
row.PowerUseEnabled,
|
||||
row.ListHandlerMaxHandoffs);
|
||||
row.ListHandlerMaxHandoffs,
|
||||
row.PowerUseWindowStart,
|
||||
row.PowerUseWindowEnd,
|
||||
row.PowerUseHandoffPct);
|
||||
}
|
||||
|
||||
public async Task UpdateAppSettings(AppSettingsDto dto)
|
||||
@@ -363,6 +366,12 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
|
||||
// The cap is what bounds a runaway handoff loop; a 0 from a stale or hand-written
|
||||
// client would remove that bound entirely, so clamp instead of trusting the wire value.
|
||||
ListHandlerMaxHandoffs = Math.Max(1, dto.ListHandlerMaxHandoffs),
|
||||
// An unparseable time string is stored as null (= no window) rather than rejected: the
|
||||
// window is an optional narrowing, and a typo must not silently mean "PowerUse never
|
||||
// applies". Below 50% a handoff threshold would fire before the session got anywhere.
|
||||
PowerUseWindowStart = PowerUseWindow.Normalize(dto.PowerUseWindowStart),
|
||||
PowerUseWindowEnd = PowerUseWindow.Normalize(dto.PowerUseWindowEnd),
|
||||
PowerUseHandoffPct = Math.Clamp(dto.PowerUseHandoffPct, 50, 99),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user