Options Page UI
Relevant source files
The following files were used as context for generating this wiki page:- src/entrypoints/options/app.tsx
- src/entrypoints/options/app-sidebar/nav-items.ts
- src/entrypoints/options/pages/api-providers/index.tsx
- src/entrypoints/options/pages/translation/index.tsx
- src/entrypoints/options/pages/config/index.tsx
- src/entrypoints/options/pages/config/manual-config-sync.tsx
- src/locales/en.yml
- src/entrypoints/options/index.html
- src/entrypoints/options/pages/translation/custom-translation-style/style-preview.tsx
The Options Page is a multi-page React application that serves as the central hub for configuring all settings for the Read Frog browser extension. It is built using the WXT framework, React, and shadcn/ui components. The page allows users to manage everything from API providers and translation behavior to UI settings and configuration backups.
The UI is structured with a persistent sidebar for navigation and a main content area that renders different settings pages based on the selected route. This architecture provides a clear and organized way for users to access and modify the extension's extensive set of features.
Architecture and Core Components
The Options Page is initialized from src/entrypoints/options/index.html, which loads the main React application script. The core of the UI is the App component, which sets up the application structure, providers, and routing.
Sources: src/entrypoints/options/index.html:15, src/entrypoints/options/app.tsx
Component Hierarchy
The following diagram illustrates the main component structure of the Options Page.
This diagram shows that the App component wraps the entire UI in necessary providers and a main layout, which includes the AppSidebar for navigation and a React Router Outlet for rendering the active settings page.
Sources: src/entrypoints/options/app.tsx:21-41
Application Entrypoint (App component)
The App component in app.tsx is the root of the React application. Its primary responsibilities are:
- Setting up Providers: It wraps the application with essential providers, including:
QueryClientProviderfor data fetching and caching via TanStack Query.ThemeProviderfor managing light/dark mode.TooltipProviderfor UI tooltips.
- Defining Layout: It establishes the main two-column layout using a
divwith Flexbox, containing theAppSidebarand the main content area. - Handling Routing: It uses
react-router'sOutletcomponent to render the appropriate page component based on the current URL.
Sources: src/entrypoints/options/app.tsx:21-41
Navigation
Navigation within the Options Page is handled by the AppSidebar component, which renders a list of navigation links. The items for this navigation are defined declaratively in a separate file.
Sources: src/entrypoints/options/app.tsx:39, src/entrypoints/options/app-sidebar/nav-items.ts
Navigation Items
The navigation links are defined in nav-items.ts. Each item has a path, an icon, and a localization key for its label. The structure is divided into two groups: "Settings" and "Product".
| Group | Path | Icon | i18n Key | Description |
|---|---|---|---|---|
| Settings | / | tabler:settings | options.general.title | General settings, including Read and Translation provider/model selection. |
| Settings | /api-providers | tabler:plug | options.apiProviders.title | Configure API keys and models for various built-in and custom AI providers. |
| Settings | /translation | tabler:language | options.translation.title | Detailed translation settings like request rate, batching, prompts, and display style. |
| Settings | /floating-button-toolbar | tabler:tool | options.floatingButtonAndToolbar.title | Enable/disable and configure the floating button and selection toolbar. |
| Settings | /tts | tabler:volume | options.tts.title | Configure Text-to-Speech settings (provider, model, voice, speed). This is a Beta feature. |
| Settings | /statistics | tabler:chart-line | options.statistics.title | View statistics, such as savings from batch translation requests. |
| Settings | /config | tabler:database | options.config.title | Manage application configuration, including manual/cloud sync, backups, and reset. |
| Product | /whats-new | tabler:gift | options.whatsNew.title | Displays information about new features and updates. |
| Product | /survey | tabler:forms | options.survey.title | A link for users to suggest new features. |
| Product | /rate-us | tabler:star | options.rateUs.title | A link for users to rate the extension. |
Sources: src/entrypoints/options/app-sidebar/nav-items.ts:3-56, src/locales/en.yml:42-261
Configuration Pages
The main content area of the Options Page renders different pages for managing specific categories of settings.
API Providers Page
This page allows users to add, edit, and delete API providers for both translation and reading functionalities. It supports a wide range of built-in providers as well as any OpenAI-compatible custom provider.
The user flow for adding a new provider is as follows:
- The user clicks the "Add Provider" button.
- A dialog opens, presenting three categories of providers:
- Built-in LLM Providers
- OpenAI Compatible Custom Providers
- Pure Translation Providers
- After selecting a provider, a form is displayed to configure its details, such as Name, API Key, Base URL, and models for reading/translation.
- The user can set the new provider as the default for translation or reading.
Sources: src/entrypoints/options/pages/api-providers/index.tsx:28-49, src/locales/en.yml:51-87
The diagram below shows the user flow for adding a new API provider.
Translation Page
The Translation page is a container for several sub-sections, each managing a specific aspect of the translation feature. It uses a PageLayout component to structure its content.
The following sections are available on the Translation page:
| Component | i18n Title | Description |
|---|---|---|
RequestQueueConfig | Translation Rate | Adjusts the token bucket algorithm parameters (capacity, rate) for translation requests. |
BatchQueueConfig | Batch Translation | Configures character and paragraph limits for batching translation requests to save costs. |
AutoTranslateWebsite | Auto Translate...Website | Manages a list of URL patterns for sites that should be automatically translated. |
PersonalizedPrompts | Personalized Prompts | Allows users to create, edit, import, and export custom prompts for LLM-based translations. |
TranslationStyle | Translation Display Style | Sets the visual style for translated text, including preset styles and custom CSS with a live preview. |
TranslationMode | Translation Mode | Choose between Bilingual and Translation Only display modes. |
PageTranslationShortcut | Page Translation Shortcut | Customize the shortcut key for translating entire web pages. |
PreloadConfig | Pre-translate Range | Control how much content below the viewport is pre-translated. |
NodeTranslationHotkey | Hover Translation Shortcut | Customize the modifier key for hover-to-translate functionality. |
AutoTranslateLanguages | Auto Translate...Language | Automatically translate pages when specific languages are detected. |
AIContentAware | AI Smart Context Translation | Enhance translation quality by providing article context to the AI. |
Sources: src/entrypoints/options/pages/translation/index.tsx:13-25, src/locales/en.yml:144-219, src/entrypoints/options/pages/translation/custom-translation-style/style-preview.tsx
Config Page
This page provides tools for managing the extension's entire configuration object. It is composed of several distinct functional cards.
| Component | i18n Title | Description |
|---|---|---|
BetaExperienceConfig | Beta Experience | A toggle to enable experimental and early-access features. |
GoogleDriveSyncCard | Google Drive Cloud Sync | Automatically syncs configuration to Google Drive. |
ManualConfigSync | Manual Config Sync | Provides buttons to manually import and export the configuration as a JSON file. |
ConfigBackup | Config Backup | Manages automatic hourly backups of the configuration, allowing users to restore, export, or delete previous versions. |
ResetConfig | Reset Config | A button to reset all settings to their default values. |
Sources: src/entrypoints/options/pages/config/index.tsx:9-15, src/locales/en.yml:223-261
Manual Config Sync
The ManualConfigSync component provides functionality to import and export configuration files.
Export Flow
When a user clicks "Export", they are prompted to either include or exclude API keys from the exported JSON file. This is a security measure to prevent accidental leakage of sensitive credentials.
Import Flow
The import process handles file reading, data parsing, configuration migration, and state updates. It also automatically creates a backup of the current configuration before applying the imported one.
Conclusion
The Options Page UI is a comprehensive and well-structured interface that provides users with granular control over the Read Frog extension's functionality. By leveraging a modern tech stack including React, WXT, and TanStack Query, it offers a reactive and user-friendly experience. The clear separation of concerns into distinct pages and components, combined with declarative definitions for navigation and robust configuration management features like import/export and backups, makes it a powerful and maintainable part of the project.