Skip to content
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

Dev 0.0.8 #156

Merged
merged 23 commits into from
Jan 16, 2025
Merged

Dev 0.0.8 #156

merged 23 commits into from
Jan 16, 2025

Conversation

crazygo
Copy link
Contributor

@crazygo crazygo commented Jan 15, 2025

Pull Request: Enhance Dropdown Components and System Prompt Management

Main Changes

This pull request primarily includes the following improvements:

1. Dropdown Component Refactoring and Standardization

  • BaseDropdown Component: Introduced as a foundational dropdown component.
  • ToolDropdown and ModelDropdown Refactoring: Reconstructed to utilize the BaseDropdown component, ensuring uniformity.
  • Enhanced Positioning Logic: Optimized the logic for dropdown positioning and event handling.
  • Improved Layout: Enhanced the arrangement of buttons and options, enhancing user experience.

2. System Prompt Management

  • SystemPromptDropdown Component: Added for managing system prompts.
  • Enhanced Message Handling: Strengthened the structure for processing and responding to system messages.
  • Improved Preset Management: Enhanced the functionality for managing presets.
  • Optimized Tool Preview: Improved the tool preview feature.

3. Performance and User Experience Enhancements

  • Input Focus Improvement: Enhanced the behavior of input focus.
  • Optimized Tooltip Positioning Logic: Improved the logic for positioning tool tooltips.
  • Simplified Event Handling: Streamlined event processing logic.
  • Eliminated Redundant Console Logs: Removed unnecessary console logging.

4. Other Improvements

  • Package Version Update: Updated to version 0.0.8.
  • .gitignore Configuration Update: Updated the .gitignore file.
  • Enhanced Logging Management: Improved logging capabilities.
  • Optimized Storage Manager Functionality: Enhanced the storage manager's features.

Technical Details

  • Dropdown Component Architecture Refactoring: Increased code reusability.
  • Component State Management Optimization: Improved state management between components.
  • Enhanced Event Handling Mechanism: Boosted the smoothness of user interactions.
  • Uniform Tool and Model Selection Logic: Standardized the selection process for tools and models.

Testing Recommendations

Please focus on testing the following functionalities:

  1. Dropdown Opening and Closing Behavior
  2. Tool and Model Selection
  3. System Prompt Switching
  4. Tool Preview Display
  5. Input Focus Management

Related Issues

  • Resolved Inaccurate Dropdown Positioning: Addressed issues with dropdown positioning.
  • Fixed Input Focus Loss: Resolved problems with input focus being lost.
  • Optimized Tooltip Display Position: Improved the display position of tool tooltips.

Changed Files

- Updated the system message in chat presets to include context analysis and structured response guidelines for improved user interaction.
- Implemented dynamic system message updates in the ChatCoreContext to ensure the latest configuration is used for each request.
- Modified StorageManager to merge user chat presets with system configurations, allowing for more personalized responses.
…structured response guidelines

- Updated the chat presets configuration to include detailed context analysis and a structured response format for improved user interaction.
- Added guidelines for analyzing user message context and formulating responses, ensuring clarity and relevance in AI interactions.
…tool preview

- Added functionality to manage system presets within the ToolDropdown component, allowing users to select and display the current preset.
- Integrated fetching of system presets and the current preset from storage, improving user experience by providing context-aware options.
- Enhanced the ToolPreview component to adjust its positioning dynamically based on cursor location, ensuring better visibility and usability.
- Updated StorageManager to support retrieval and storage of system presets, streamlining the configuration process for user tools.
…onality

- Added SystemPromptDropdown to AskPanel for improved user interaction.
- Removed unused state and logic related to system presets in ToolDropdown, simplifying the component.
- Adjusted dropdown item layout in ModelDropdown for better readability and user experience.
- Updated display name truncation in ModelDropdown for enhanced visibility.
- Refactored SystemPromptDropdown to utilize MenuItem and Transition components for improved dropdown behavior and animations.
- Updated dropdown item layout for better readability and user interaction, including an index display for system presets.
- Enhanced styling for the dropdown button and items to improve visual consistency and accessibility.
- Integrated mouse event handling to maintain dropdown visibility, ensuring a smoother user experience.
- Implemented a new asynchronous model fetching function to retrieve user models from storage, improving data handling.
- Added detailed logging throughout the component to assist in debugging and provide better insights into the dropdown's state and actions.
- Removed redundant model fetching logic to streamline the component's functionality.
- Updated the display name handling for improved clarity in the dropdown items.
…ropdown component

- Updated ToolDropdown and ModelDropdown to utilize the new BaseDropdown component for improved code reusability and maintainability.
- Added 'id' property to ToolsPromptInterface and ModelItem for better identification of dropdown items.
- Streamlined dropdown item rendering and event handling, enhancing user interaction and visual consistency.
- Removed redundant state management and logging, simplifying component logic and improving performance.
…wn and dropdown management

- Added SystemPromptDropdown to AskPanel, improving user interaction with system presets.
- Introduced state management for the new system prompt dropdown, allowing for better control and visibility.
- Refactored ToolDropdown to remove unused state and streamline functionality.
- Enhanced BaseDropdown to support selected item highlighting and improved rendering logic.
- Updated SystemPromptDropdown to utilize BaseDropdown for consistent behavior and styling across dropdowns.
- Improved logging and event handling for better debugging and user experience.
…down components

- Added statusListener calls to ToolDropdown, SystemPromptDropdown, and ModelDropdown to improve state management upon item selection.
- Implemented Enter key support in ModelDropdown for better accessibility and user interaction.
- Enhanced logging in BaseDropdown for improved debugging and tracking of user actions.
- Streamlined event handling across dropdown components to ensure consistent behavior and responsiveness.
- Updated button class to limit maximum width for better responsiveness.
- Reduced maximum width of displayed item name for enhanced visibility.
- Modified shortcut key display to ensure consistent layout and prevent overflow.
- Improved icon layout to maintain visual consistency within the dropdown.
- Eliminated console log statements from SystemPromptDropdown, ModelDropdown, and BaseDropdown for cleaner code and improved performance.
- Updated event handling in SystemPromptDropdown to include onMouseDown for better user interaction.
- Streamlined dropdown components by refining the useEffect hooks and ensuring consistent behavior across dropdowns.
- Commented out focus calls in AskPanel to prevent unwanted input field focus behavior.
- Updated onClick handlers in ToolDropdown and ModelDropdown for improved clarity and consistency.
- Refactored ModelDropdown to simplify item click handling and enhance readability.
- Enhanced BaseDropdown to manage command key state more effectively and improve item rendering logic.
… logs

- Refactored tooltip positioning in ToolPreview to improve alignment with the cursor and menu items.
- Commented out erroneous calculations for tooltip placement and added console logs for better debugging.
- Updated useToolPreview hook to correct vertical positioning of the tooltip based on button height.
- Re-enabled input focus calls in AskPanel to ensure the input field receives focus as intended.
- Adjusted timing for focus calls to improve user experience during dropdown interactions.
- Bumped version from 0.0.6 to 0.0.7 in package.json and updated the description to clarify the purpose of the Askman extension.
- Modified BaseDropdown component to display 'Untitled' for unnamed items, improving user experience by providing a default label when displayName is not a string.
- Enforced the 'template' property in SystemPresetInterface to be required, ensuring better type safety in the StorageManager utility.
…oning and event handling

- Updated ToolDropdown, SystemPromptDropdown, and ModelDropdown to utilize useRef for better reference management.
- Adjusted tooltip positioning logic in useToolPreview to align previews more accurately with dropdown items.
- Enhanced BaseDropdown to support right alignment for dropdown menus, improving layout flexibility.
- Streamlined event handling in dropdown components for improved user interaction and responsiveness.
- Added .vscode and .cursor to .gitignore to prevent unnecessary files from being tracked in the repository.
- Ensured that the .gitignore file is up to date with the latest development environment configurations.
…eview

- Removed console log statements in AskPanel and useToolPreview to clean up the code and improve performance.
- This change enhances the overall readability and maintainability of the components without affecting functionality.
…lity

- Updated BaseDropdown component to improve button styling by adding a 'group' class for better hover effects.
- Refactored item display logic to include a tooltip that appears on hover, providing additional context for unnamed items.
- Ensured consistent display of 'Untitled' for unnamed items while maintaining accessibility through title attributes.
- Enhanced layout structure for improved usability and visual clarity.
…onents

- Updated ToolDropdown and ModelDropdown to utilize a consistent approach for managing selected tools and models, enhancing state management.
- Replaced `getSelectedModel` with `getCurrentModel` in configStorage for improved clarity and consistency in naming.
- Introduced `setCurrentTool` and `setCurrentModel` methods in StorageManager for better encapsulation of tool and model state.
- Enhanced dropdown components to reflect the currently selected tool or model, improving user experience and interaction.
- Streamlined event handling in dropdowns to ensure consistent behavior across components.
@crazygo crazygo requested a review from Copilot January 15, 2025 17:15
@crazygo crazygo added this to the 2025-01 milestone Jan 15, 2025
@crazygo crazygo mentioned this pull request Jan 15, 2025
23 tasks
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 14 changed files in this pull request and generated 1 comment.

Files not reviewed (8)
  • package.json: Language not supported
  • src/components/ask-panel.tsx: Evaluated as low risk
  • src/components/ask/ModelDropDown.tsx: Evaluated as low risk
  • src/components/ask-tooldropdown.tsx: Evaluated as low risk
  • src/shared/storages/configStorage.ts: Evaluated as low risk
  • src/chat/chat.ts: Evaluated as low risk
  • src/types.ts: Evaluated as low risk
  • src/components/tool-preview.tsx: Evaluated as low risk
Comments suppressed due to low confidence (5)

src/utils/StorageManager.ts:254

  • The comment is in Chinese. It should be translated to English for consistency: 'If userConfigObj is an array, do not merge'.
// 如果 userConfigObj 是数组,则不合并

src/utils/StorageManager.ts:215

  • Ensure that Handlebars.compileAST returns a TemplateDelegate to avoid type inconsistencies with the SystemPresetInterface.
template: Handlebars.compileAST(preset.system)

src/utils/StorageManager.ts:237

  • The key 'current-tool' should be defined as a constant to avoid potential typos and improve maintainability.
return await StorageManager.get('current-tool');

src/utils/StorageManager.ts:163

  • Ensure that the merging logic of chatPresets and userChatPresets does not unintentionally overwrite important configurations.
const mergedConfig = { ...chatPresets, ...userChatPresets };

src/utils/StorageManager.ts:181

  • Ensure that the fallback mechanism for the 'system-init' preset is properly tested to avoid any runtime issues.
const template = Handlebars.compileAST(mergedConfig['system-init'].system);

className={`${
active ? 'bg-black text-white' : 'text-gray-900'
} group flex w-full items-center rounded-md px-2 py-2 text-sm focus:outline-none`}
onMouseDown={() => handleSystemPresetClick(preset)}
Copy link
Preview

Copilot AI Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handleSystemPresetClick function is called twice on onMouseDown and onClick events. Remove one of the event handlers to avoid duplicate calls.

Suggested change
onMouseDown={() => handleSystemPresetClick(preset)}
onClick={() => handleSystemPresetClick(preset)}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For touchpad operations, a light touch is a click operation, and pressing down is a mousedown operation

…wn export

- Added functionality to fetch the currently selected tool from StorageManager in AskPanel, improving user experience by maintaining tool state.
- Enhanced ToolDropdown by exporting the tools array for better accessibility in other components.
- Integrated Handlebars compilation for user-defined tools, allowing for dynamic template rendering.
- Improved error handling during tool fetching to ensure robustness.
@crazygo
Copy link
Contributor Author

crazygo commented Jan 15, 2025

Features

  • ask-panel: implement tool fetching logic and enhance ToolDropdown export (3516b48)
  • dropdowns: enhance event handling and status management in dropdown components (a412e01)
  • ask-panel, system-prompt-dropdown: integrate SystemPromptDropdown and dropdown management (e8e75b8)
  • ModelDropdown: refactor model fetching and enhance logging (32baf39)
  • system-prompt-dropdown: enhance dropdown functionality and styling (84483b7)
  • tool-dropdown: implement system presets management and enhance tool preview (988b568)
  • chat: enhance system message handling and response structure (6fb1b36)

Bug Fixes

  • ask-panel: restore input focus behavior in AskPanel component (07acc8e)
  • tool-preview: adjust tooltip positioning logic and add debugging logs (249cf85)
  • BaseDropdown: adjust button and item layout for improved usability (e9fedb2)

Refactors

  • dropdowns: unify tool and model selection logic across components (24d8a86)
  • BaseDropdown: enhance dropdown button and tooltip functionality (898e7d2)
  • logging: comment out console logs in AskPanel and useToolPreview (cd0d51f)
  • dropdowns: enhance dropdown components with improved positioning and event handling (fe099cb)
  • dropdowns: streamline event handling and remove focus calls (c5f9583)
  • dropdowns: remove console logs and enhance event handling (8ffb9d7)

Chores

  • bump package version to 0.0.8 in package.json (6ac13a9)
  • update .gitignore to include .vscode and .cursor files (1c3510a)
  • update package version and enhance BaseDropdown display logic (5241bdf)
  • remove unused commit-msg.zh file (9dd1c91)

@crazygo crazygo merged commit fda6a7a into main Jan 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant