-
Notifications
You must be signed in to change notification settings - Fork 3.3k
CherryStudio v2: Data & UI Refactoring #10162
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
Draft
0xfullex
wants to merge
295
commits into
main
Choose a base branch
from
v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+66,475
−9,992
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Removed the App_SetTheme IPC channel and related theme management code. - Updated imports to use preferenceTypes for theme and selection action items. - Refactored preference service to preload preferences and adjusted related components. - Cleaned up unused code and comments related to theme management. - Enhanced the organization of preference-related types and actions for better maintainability.
- Commented out the App_SetLanguage IPC channel and related language management code. - Updated preferences to use LanguageVarious type for language settings. - Removed the locales utility file and adjusted imports to utilize preferenceService for language management. - Cleaned up unused code and comments related to language handling for improved maintainability.
- Commented out the App_SetDisableHardwareAcceleration IPC channel and related code for hardware acceleration settings. - Updated preferences to utilize the new WindowStyle type for window style settings. - Refactored components to use the usePreference hook instead of useSettings for better preference management. - Cleaned up unused code and comments related to hardware acceleration and window style for improved maintainability.
- Updated preferences to utilize the new SendMessageShortcut type for better type safety. - Refactored components to use the usePreference hook instead of useSettings for improved preference handling. - Added new preferences for target language and send message shortcut in various components. - Cleaned up unused code and comments related to settings for better maintainability. - Updated auto-generated preference mappings to reflect recent changes in preference structure.
- Updated preference keys from 'app.theme.*' to 'ui.*' for better organization and clarity. - Introduced new preferences for assistant tab sorting and visibility. - Refactored components to utilize the updated preference keys, improving consistency across the codebase. - Cleaned up unused code and comments related to previous settings for maintainability. - Updated auto-generated preference mappings to reflect the new structure.
- Updated preferences to include new confirmation settings for message actions, allowing users to customize action confirmations. - Refactored components to utilize the usePreference hook for improved preference handling, replacing previous useSettings references. - Introduced new types for AssistantIconType and SidebarIcon to enhance type safety. - Cleaned up unused code and comments related to previous settings for better maintainability. - Updated auto-generated preference mappings to reflect recent changes in preference structure.
…ions - Updated preference handling to utilize the usePreference hook across various components, improving consistency and maintainability. - Introduced new preference types for ProxyMode and MultiModelFoldDisplayMode to enhance type safety. - Refactored components to replace useSettings with usePreference, streamlining preference management. - Cleaned up unused code and comments related to previous settings for better clarity. - Updated auto-generated preference mappings to reflect recent changes in preference structure.
…ration - Commented out the UpgradeChannel enum in constant.ts and moved it to preferenceTypes.ts for better organization. - Updated various components to utilize the new UpgradeChannel type from preferenceTypes, enhancing type safety and consistency. - Refactored preference handling across multiple files to streamline the use of the usePreference hook, replacing previous settings references. - Cleaned up unused code and comments related to previous settings for improved maintainability. - Updated auto-generated preference mappings to reflect recent changes in preference structure.
…grations - Updated various components to utilize the usePreference hook, replacing previous useSettings references for improved consistency and maintainability. - Introduced new preference types for ChatMessageStyle, ChatMessageNavigationMode, and MultiModelMessageStyle to enhance type safety. - Refactored preference handling in multiple files, ensuring a more streamlined approach to managing user preferences. - Cleaned up unused code and comments related to previous settings for better clarity and maintainability. - Updated auto-generated preference mappings to reflect recent changes in preference structure.
- Introduced a detailed SettingsState interface, incorporating various user preferences such as showAssistants, language settings, proxy configurations, and more. - Updated initialState to reflect the new comprehensive settings structure, ensuring all preferences are initialized correctly. - Cleaned up commented-out code and organized settings for improved clarity and maintainability. - Enhanced type safety by integrating new types for various settings, aligning with recent refactoring efforts in preference management.
… documentation - Updated preferences types in preferences.ts to use PreferenceTypes for better type safety. - Added new preference keys related to notes features in preferences.ts. - Enhanced documentation in PreferenceService.ts and usePreference.ts to clarify usage and update strategies. - Improved caching and subscription mechanisms in PreferenceService for better performance and reliability.
- Replaced useSettings with usePreference in PinnedMinapps and useMinappPopup components for better preference handling. - Added external dependency for Electron in electron.vite.config.ts and set output format to CommonJS.
- Replaced instances of useSettings with usePreference for better preference handling across various components. - Updated function signatures to support async operations where necessary. - Adjusted imports to utilize shared configuration for prompts, enhancing consistency in prompt management. - Improved error handling and logging in AI-related functionalities.
…er imports in MiniWindowApp
…ency - Removed deprecated selection IPC channels from IpcChannel. - Replaced string literals with enums for SelectionTriggerMode and SelectionFilterMode in preference management. - Updated the SelectionService and selectionStore to utilize the new enum types for better type safety and clarity. - Marked selectionStore as deprecated for future removal after data refactoring.
- Introduced new IPC channels for Data API requests and responses in IpcChannel. - Added swr library to package.json for improved data fetching capabilities. - Updated preload API to include Data API related methods for handling requests and subscriptions. - Removed deprecated pending_default_values.ts file as part of data refactor.
…components - Eliminated AbortSignal handling from ApiClient interface and DataApiService to streamline request processing. - Updated IpcAdapter to remove event sender logic for responses, aligning with the new direct IPC approach. - Adjusted tests to reflect the removal of cancellation capabilities, emphasizing that direct IPC requests cannot be cancelled. - Cleaned up related code and comments to enhance clarity and maintainability.
- Updated preferences configuration with new user theme options including font family and code font family. - Added new preferences for chat and export menus. - Adjusted default preferences to include new settings for user theme. - Enhanced useUserTheme hook to manage new font family preferences.
- Deleted the DmxapiToImg SVG file and its corresponding React component to streamline the icon library. - Updated index.ts and Logos.stories.tsx to remove references to DmxapiToImg, ensuring consistency across the codebase.
- Added an init method to DbService for database initialization, ensuring it is called before migrations. - Updated the migrateDb and migrateSeed methods to check if the database is initialized, improving error handling. - Called dbService.init() in the app's whenReady event to ensure proper database setup during startup.
…reference schemas - Introduced a new ESLint rule to enforce a specific naming convention for schema keys: `namespace.sub.key_name`. - Updated cache and preference schema files to include documentation on the naming convention and examples of valid/invalid keys. - Modified existing keys in cache schemas to comply with the new convention.
- Add 24 new preference mappings including memory (3), note (10),
theme fonts, sidebar icons, and message settings
- Move memory prompts to shared config for reuse across processes
- Regenerate preference schemas with 6 new memory config items
- Fix math_engine mapping path (chat.message.math_engine → chat.message.math.engine)
- Update mapping stats: 175 → 199 Redux items, 197 → 203 total configs
- Replace direct Redux state access for memory preferences with preferenceService calls in multiple components. - Introduce new preference mappings for memory settings, including 'feature.memory.auto_dimensions'. - Remove deprecated preference mappings and update default preferences accordingly. - Regenerate preference schemas to reflect the latest changes in memory configuration.
- Add data-classify tools for data inventory extraction and code generation - Include consolidated Chinese documentation (README.md) - Update generated file path references This temporary directory will be removed after V2 refactor is complete.
- Assign @0xfullex as the code owner for the new v2-refactor-temp directory to streamline collaboration during the V2 refactoring process.
5 tasks
…ng in Inputbar components Updated the Inputbar and AgentSessionInputbar components to use the new cacheService for managing draft persistence and mentioned models, ensuring consistency across the application.
* refactor(ui): migrate switch component from heroui to radix-ui replace heroui switch implementation with radix-ui for better maintainability update package.json and yarn.lock to include new dependency * fix(eslint): enable heroui import restriction for deprecated Switch component * refactor(ui): update Switch component props from isSelected/onValueChange to checked/onCheckedChange Standardize Switch component props across the codebase to use checked/onCheckedChange instead of isSelected/onValueChange for better consistency with common React patterns. Also updates loading state prop from isLoading to loading and removes size prop where unnecessary. The changes include: - Replacing isSelected with checked - Replacing onValueChange with onCheckedChange - Updating isLoading to loading - Removing redundant size props - Adjusting styling to accommodate new loading state * refactor(switch): improve switch component styling and structure - Add default values for loading and disabled props - Update styling classes and add group cursor pointer - Restructure loading indicator and thumb positioning - Wrap DescriptionSwitch children in flex container * refactor(ui): improve switch component structure and usage - Restructure DescriptionSwitch to use explicit props instead of children - Add label, description, and position props for better customization - Update all switch usages in SettingsTab to use new props format * refactor(primitives): simplify switch props by omitting children Remove redundant children prop from CustomSwitchProps since it's already omitted from the parent type * fix(switch): add useId for label accessibility in DescriptionSwitch Ensure proper label association with switch input by generating unique ID using React's useId hook * refactor(settings): remove commented out SettingRowTitleSmall components * refactor(SettingsTab): add todo comment for memoization optimization * feat(switch): add size prop to customize switch dimensions Add sm, md, and lg size options to the Switch component with corresponding styles. This allows for better visual consistency across different UI contexts. * style(ui): adjust switch component styling and theme colors update switch component layout and spacing to improve consistency modify secondary-foreground color variable to use correct semantic token * feat(switch): add new switch component styles and animations - Add new switch.css file with gradient and transition styles - Update switch.tsx component with new styling classes and animations - Remove loader icon in favor of animated gradient effect * fix(i18n): Auto update translations for PR #11061 * style(primitives): remove redundant border style from switch component * refactor(switch): remove switch.css and update switch component styles Remove deprecated switch.css file and migrate styles to inline tailwind classes. Update disabled state styling to use opacity instead of linear gradient for better consistency. * refactor(switch): simplify switch thumb implementation Replace complex div structure with svg for loading state Adjust disabled opacity and loading state styling * style(switch): adjust thumb size and positioning for better consistency * feat(switch): add storybook documentation for switch component Add comprehensive Storybook documentation for the Switch component, including: - Basic usage examples - Different states (checked, disabled, loading) - Size variations - DescriptionSwitch variant - Real-world usage scenarios - Accessibility examples - Form integration examples Also remove redundant box-content class from switch styles * fix(switch): adjust thumb positioning for md and lg sizes * style(primitives): improve switch component styling and spacing - Add padding to the container - Simplify label height logic - Update typography classes for better consistency - Adjust switch container alignment * feat(switch): add size prop to DescriptionSwitch component Add support for sm, md, and lg sizes to DescriptionSwitch component with responsive text sizing. Also includes comprehensive Storybook documentation with examples of all sizes and states. * style(switch): align label text to right when isLeftSide is true * refactor(stories): clean up DescriptionSwitch stories by removing unused imports and simplifying JSX * refactor(ui): rename CustomizedSwitch to Switch for consistency Simplify component naming by removing redundant 'Customized' prefix and aligning with common naming conventions * refactor(switch): extract switch root styles into cva variants Improve maintainability by using class-variance-authority to manage switch root styles and variants * refactor(switch): extract thumb variants into separate cva function Improve maintainability by moving switch thumb styling logic into a dedicated variants configuration. This makes the component more readable and easier to modify. * feat(switch): add classNames prop for custom styling Allow custom class names to be applied to switch root, thumb, and thumbSvg elements for more flexible styling options. * feat(switch): add loading animation variants for switch thumb Extract loading animation logic into separate cva variants for better maintainability and reusability --------- Co-authored-by: GitHub Action <[email protected]>
* feat(input): add new input component and update eslint config Add new custom input component to replace antd and heroui inputs Update eslint config to enforce using the new input component * feat(input): refactor input component to support compound pattern Add new Input component with support for Password and Button variants through compound pattern. Move input implementation to new directory structure and enhance with label and caption support. Remove old input implementation. * refactor(input): consolidate input components and update exports Move input component files to lowercase directory and simplify structure Remove unused button and password input components Update exports in components index file * refactor: replace antd Input with @cherrystudio/ui Input across components * feat(primitives): add textarea component to ui primitives * feat(primitives): add input-group component with variants and controls build: update @radix-ui/react-slot dependency to v1.2.4 * refactor(ui): simplify input component and update usage Remove complex Input component implementation and replace with simpler version Update components to use new Input and Textarea components from ui package * feat(ui): add composite input component and utility functions - Introduce new CompositeInput component with variants and password toggle - Add utility functions for null/undefined conversion - Export new components and types from index - Update input props interface and usage in input-group * feat(Input): refactor CompositeInput component and add stories - Refactor CompositeInput component with improved variants and styling - Add comprehensive Storybook stories for Input, InputGroup and CompositeInput components - Implement password toggle functionality and button variants - Include accessibility features and interactive examples * feat(input): improve disabled state styling and behavior - Add disabled state variants for input components - Ensure password toggle button respects disabled state - Update disabled styling for better visual consistency - Add storybook examples for disabled password inputs * feat(input): add validation states and form examples - Implement validation states for input components - Add real-time validation examples - Create form validation demos for different input types - Update styling for disabled and invalid states * feat(input): add prefix support for email variant input Add prefix variants styling and prefix prop to CompositeInput component to support email inputs with fixed prefixes. Update stories to demonstrate various prefix use cases and interactive examples. * refactor(Input): simplify content rendering logic by removing useMemo hooks The startContent and endContent memoized values were removed and their logic was inlined directly in the JSX. This makes the code more straightforward and removes unnecessary memoization overhead since the calculations are simple. * feat(Input): add select variant to CompositeInput component Add new 'select' variant to CompositeInput component with support for select dropdown groups and items. Includes styling variants, type exports, and comprehensive storybook examples demonstrating various use cases like currency input, URL with protocol, phone with country code, and temperature with unit selectors. * Revert "refactor: replace antd Input with @cherrystudio/ui Input across components" This reverts commit f7f689b. * fix(CompositeInput): handle missing props gracefully by returning null Add null checks for email and select variants to prevent rendering issues when required props are missing * fix(Input): adjust select prefix and trigger styling Update select prefix variants to remove redundant padding and simplify size variants. Add new selectTriggerVariants for consistent styling across sizes. * feat(storybook): add playground story for InputGroup component Add interactive playground story with controls for all InputGroup props including addons, button variants and input types * style(primitives): remove redundant border radius from input group variants * style(input): adjust button and label variant styling Refactor variant classes to use string literals instead of arrays for better readability * refactor(Input): simplify variant class strings in input component --------- Co-authored-by: MyPrototypeWhat <[email protected]> Co-authored-by: fullex <[email protected]>
- Replace local imports of Input and Switch components with imports from the @cherrystudio/ui package for consistency. - Minor adjustment to the Switch story to include a button type for the toggle state functionality.
- Removed the config module and replaced its usage with preferenceService across the API server implementation. - Updated the auth middleware to retrieve the API key from preferenceService instead of the config. - Adjusted the ApiServerService to ensure a valid API key is generated and stored in preferences. - Refactored the useApiServer hook to utilize the new preference system for API server configuration. - Updated related tests to mock preferenceService instead of config. - Cleaned up unused imports and adjusted related components to align with the new configuration approach.
- Renamed `Preference_GetMultiple` to `Preference_GetMultipleRaw` in IpcChannel for clarity. - Introduced `MultiPreferencesResultType` to better map requested keys to their values or undefined in preferenceTypes. - Updated `PreferenceService` to implement `getMultipleRaw` for synchronous access to multiple preferences. - Adjusted related components and services to utilize the new method for fetching multiple preferences. - Cleaned up imports and ensured consistent usage across the application.
- Updated ApiServerService and ClaudeCodeService to use the new `getMultiple` method for fetching API server configuration from the preference service. - Simplified the structure of the returned configuration object, enhancing readability and maintainability. - Removed deprecated raw preference retrieval methods in favor of the new mapping approach.
…type - Renamed `MultiPreferencesResultType` to `PreferenceMultipleResultType` for clarity and consistency. - Updated `getMultipleRaw` method in `PreferenceService` to reflect the new type name. - Adjusted related components and services to utilize the updated type, ensuring consistent usage across the application.
…mpatibility - Added comments in theme.css and theme.css files to explain the changes in spacing variable definitions. - Temporarily commented out the `--spacing-5xs` variable due to significant differences with container spacing in Tailwind CSS v4. - Ensured clarity on the priority of CSS variable resolution in Tailwind CSS.
…k examples - Updated DialogContent styling to use a rounded border and improved shadow effects for better visual appeal. - Introduced a new Storybook file for the Dialog component, featuring multiple stories that demonstrate various use cases, including default, alert, form, and customizable dialogs. - Enhanced accessibility and usability by providing examples for different dialog configurations and actions.
…istency - Changed button border radius from rounded-md to rounded-xs for a sleeker look. - Adjusted padding to py-2 px-4 to reduce button size and enhance usability. - Updated hover effect to use shadow-xs for a more subtle interaction feedback. - Simplified size variants by removing unnecessary padding adjustments.
…Storybook examples - Introduced a new ConfirmDialog component for confirmation scenarios, integrating Dialog and Button primitives. - Added props for customizable titles, descriptions, and button texts, including support for loading states and destructive actions. - Created Storybook stories demonstrating various use cases, including default, destructive, and custom content scenarios.
…amples (#11260) * feat(textarea): add Textarea component with variants and Storybook examples * feat(textarea): enhance Textarea component with context, improved variants, and Storybook examples * Fine-tuning the style * fix ci * feat(textarea): refactor Textarea stories to use custom label and caption components * feat(textarea): add TextareaContext for managing textarea state * fix: format * feat(textarea): refactor TextareaInput to simplify props and remove autoSize handling * feat(textarea): remove TextareaContext and update stories to reflect new error handling * refactor(textarea): remove TextareaRoot component After removing TextareaContext, TextareaRoot became a simple wrapper div with no functionality beyond applying layout styles. This change: - Removes TextareaRoot component and its exports - Updates all Storybook stories to use plain divs with the same styling - Simplifies the component API while maintaining the same functionality Addresses reviewer feedback: #11260 (comment) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: format --------- Co-authored-by: Claude <[email protected]> Co-authored-by: MyPrototypeWhat <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CherryStudio v2 including Data Refactoring and UI Refactoring.
This is the largest code refactoring project in Cherry Studio's history
Guide
Production Plan
The v2 is scheduled for release in v2.0.0.
Contribution
Welcome developers to refactor the features or modules they have maintained according to the new data architecture and UI architecture, which will greatly accelerate our refactoring efforts.
If you'd like to optimize existing code, please submit your changes via a PR to the
v2branch.We will ultimately use the
merge commitsmethod to mergev2into themainbranch, which will preserve each of your PR commits and count them toward your contributions.Data Refactoring
Coordinator: @0xfullex
Fundamentally transforming the data architecture of Cherry Studio (including data structures, storage, transmission, and usage). After the refactoring, Cherry Studio's data performance, stability, and security will be significantly improved.
Since the data affects all features and modules, this means all features and modules will also undergo refactoring and optimization alongside the data changes.
Run & Test
Currently in the testing phase, data migration will occur automatically, but no additions, deletions, or modifications will be made to the original data.
This means both old and new data coexist, and you can switch back to other branches at any time without issues or concerns.
To test the data migration process again, you can delete the
cherrystudio.sqlitefile in the data directory.Progress
Overall progress: 23%
File Structure
Note: Data refactoring is still in progress, and related APIs may change before the v2 launch.
For renderer use: README.md
For main use: README.md
For shared types: README.md
UI Refactoring
Coordinator: @MyPrototypeWhat
Migration Strategy Update:
From: antd + styled-components + HeroUI → To: shadcn/ui + Tailwind CSS
Approach: Progressive migration based on component extraction criteria
Design System: Custom CSS variables integrated with Tailwind CSS
Component Extraction Criteria:
Only migrate components that meet our extraction standards (usage ≥ 3, future reusability, etc.)
Focus on primitives, icons, and composites architecture
Prioritize backward compatibility and designer collaboration
Migration Steps
--cs-*namespace• Created theme.css mapping all design tokens to standard Tailwind classes
• Extended Tailwind with semantic spacing (5xs
8xl) and radius (4xs3xl) systems• Established two usage modes: full override and selective override
• Cleaned up main package's conflicting Shadcn theme definitions
• Remove antd dependencies, replace with shadcn/ui
• Remove HeroUI dependencies, replace with shadcn/ui
• Remove styled-components, replace with Tailwind CSS + design system variables
• Optimize component APIs and type definitions
• Ensure visual consistency and user experience
• Performance optimization and code quality improvement
Directory Structure Guide
Usage Example
After:
Related Refactoring