Repository navigation
feat: show DeepSeek peak and off-peak pricing - #280
Conversation
Finesssee
left a comment
There was a problem hiding this comment.
Requesting changes for one confirmed schedule bug and a broader structural regression. The midnight transition must be corrected, and the pricing observer should be consolidated instead of coupling per-webview polling, browser events, duplicate reads, and notification side effects. Please also preserve the typed pricing-period model across the Rust/bridge boundary. The hosted check passes, but this UI-affecting change still needs fresh Windows/CUA proof per the repository process.
| // 00:00-01:00 and 10:00-24:00 are off-peak. Use the next day's 01:00 | ||
| // as the transition so the reported instant always changes the period. | ||
| let next = DateTime::<Utc>::from_naive_utc_and_offset( | ||
| (now.date_naive() + chrono::Days::new(1)) |
There was a problem hiding this comment.
This fallback also handles 00:00-01:00, but it unconditionally adds one day. At 00:30 UTC the function therefore reports tomorrow at 01:00 (24.5 hours away) instead of today at 01:00 (30 minutes away). Please choose today's 01:00 before that boundary and tomorrow's 01:00 after 10:00, and add a deterministic status_at(at(0, 30)) test.
| const [themePreference, setThemePreference] = useState<ThemePreference>("dark"); | ||
|
|
||
| useTheme(themePreference); | ||
| useDeepSeekPricingStatus(); |
There was a problem hiding this comment.
This mounts the polling hook in every AppInner, so main, settings, float-bar, and detached webviews can each own a minute timer. The hook then forwards data through a window-local CustomEvent, while each DeepSeek MenuCard invokes the same command again; that "get" command also mutates notification state and can show a toast. This works, but it makes one concern a duplicated cross-layer pipeline. Please use one Rust-owned observer (sleeping until the exact next transition), keep status retrieval pure, update notifications once, and emit a typed Tauri event for UI subscribers. That removes the per-webview intervals, custom browser event, duplicate reads, and repeated settings loads.
| #[derive(Debug, Clone, Serialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct DeepSeekPricingStatus { | ||
| pub period: &'static str, |
There was a problem hiding this comment.
PricingPeriod is already a typed domain enum, but this boundary flattens it to a string; NotificationManager then stores another String, TypeScript redeclares the union, and the UI/notification matches use silent fallback branches. Please make the enum serializable with the bridge casing and pass it directly to notification logic. Keeping this exhaustive removes duplicated representations and prevents a future period from silently acquiring "standard" behavior.
Summary
Verification
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.