import { StrictMode, useRef, useState } from 'react'; import { createRoot } from 'react-dom/client'; import { mockIPC } from '@tauri-apps/api/mocks'; import { I18nProvider } from '../../src/i18n'; import { FloatingNotice, MessageNotice, useAppNotice } from '../../src/appNotice'; import { UsageRecordsPage } from '../../src/pages/UsageRecordsPage'; import { AgentConfigurationFeedback } from '../../src/pages/AgentControls'; import { useConfirmation } from '../../src/components/ConfirmationDialog'; import { QuotaActionFeedback } from '../../src/components/QuotaActionFeedback'; import '../../src/styles/index.css'; const params = new URLSearchParams(location.search); localStorage.setItem('easy-cli-proxy-api.locale', params.get('locale') ?? 'zh-CN'); localStorage.setItem('cpa-gui.usage-records-tab.v1', 'pricing'); document.documentElement.dataset.theme = params.get('theme') ?? 'light'; const fixture = window as typeof window & { feedbackFixture: { failSync: boolean } }; fixture.feedbackFixture = { failSync: false }; mockIPC(async (cmd) => { if (cmd === 'set_app_locale') return null; if (cmd === 'get_usage_collector_status') return { state: 'collecting', totalRecords: 1 }; if (cmd === 'get_usage_analysis') return { models: [], providers: [], sources: [], apiKeys: [] }; if (cmd === 'get_usage_pricing') return { rows: [{ model: 'test-model', requests: 1, totalTokens: 100, estimatedCost: 0, price: null }], totalCost: 0, totalRequests: 1, pricedRequests: 0, savedPrices: 0, }; if (cmd === 'preview_usage_model_prices') { if (fixture.feedbackFixture.failSync) throw new Error('price sync failed'); return { source: 'Models.dev', sourceUrl: 'https://models.dev/api.json', unmatched: [], matches: [{ model: 'test-model', prompt: 2, completion: 6, cache: 0, cacheRead: 0, cacheCreation: 0, promptConfigured: true, completionConfigured: true, cacheReadConfigured: false, cacheCreationConfigured: false, source: 'models.dev', sourceModelId: 'openai/test-model', updatedAtMs: 0 }], }; } if (cmd === 'apply_usage_model_prices') return { imported: 1 }; if (cmd === 'save_usage_model_price' || cmd === 'delete_usage_model_price') return null; throw new Error('Unexpected fixture command: ' + cmd); }, { shouldMockEvents: true }); function Fixture() { const first = useAppNotice(); const second = useAppNotice(); const [agent, setAgent] = useState(false); const [quota, setQuota] = useState(false); const [nativeError, setNativeError] = useState(''); const { askConfirmation, confirmationDialog } = useConfirmation(); const [mounted, setMounted] = useState(true); const dialog = useRef(null); return
{mounted && <> }
Existing form
{quota && }
{confirmationDialog}

Native backup dialog

setNativeError('')} />
; } createRoot(document.getElementById('root')!).render( {params.get('scenario') === 'pricing' ? : } );