-
Notifications
You must be signed in to change notification settings - Fork 96
feat: show DeepSeek peak and off-peak pricing #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import { FLOATBAR_WINDOW_LABEL } from "./floatbar/api"; | |
| import { LocaleProvider } from "./i18n/LocaleProvider"; | ||
| import type { BootstrapState, ThemePreference } from "./types/bridge"; | ||
| import type { SurfaceSnapshot } from "./hooks/useSurfaceSnapshot"; | ||
| import { useDeepSeekPricingStatus } from "./hooks/useDeepSeekPricingStatus"; | ||
|
|
||
| const Settings = lazy(() => import("./surfaces/Settings")); | ||
| const PopOutPanel = lazy(() => import("./surfaces/PopOutPanel")); | ||
|
|
@@ -62,6 +63,7 @@ function AppInner() { | |
| const [themePreference, setThemePreference] = useState<ThemePreference>("dark"); | ||
|
|
||
| useTheme(themePreference); | ||
| useDeepSeekPricingStatus(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mounts the polling hook in every |
||
|
|
||
| const reloadBootstrapState = useCallback( | ||
| () => getBootstrapState(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { useEffect } from "react"; | ||
| import { getDeepSeekPricingStatus } from "../lib/tauri"; | ||
| import type { DeepSeekPricingStatus } from "../types/bridge"; | ||
|
|
||
| export const DEEPSEEK_PRICING_EVENT = "codexbar:deepseek-pricing"; | ||
|
|
||
| export function useDeepSeekPricingStatus(): void { | ||
| useEffect(() => { | ||
| let cancelled = false; | ||
| const poll = () => { | ||
| getDeepSeekPricingStatus() | ||
| .then((status) => { | ||
| if (!cancelled && status) { | ||
| window.dispatchEvent( | ||
| new CustomEvent<DeepSeekPricingStatus>(DEEPSEEK_PRICING_EVENT, { | ||
| detail: status, | ||
| }), | ||
| ); | ||
| } | ||
| }) | ||
| .catch(() => {}); | ||
| }; | ||
| poll(); | ||
| const timer = window.setInterval(poll, 60_000); | ||
| return () => { | ||
| cancelled = true; | ||
| window.clearInterval(timer); | ||
| }; | ||
| }, []); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PricingPeriodis already a typed domain enum, but this boundary flattens it to a string;NotificationManagerthen stores anotherString, 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.