Skip to content

refactor #59

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Testudinidae
Copy link
Contributor

@Testudinidae Testudinidae commented Aug 8, 2025

Refactor / Naming / Consistency

  • Renamed Resources keys from “code-oriented” to “UI-oriented” to avoid ambiguous keys.
  • Refactored OpenHomePage logic: OpenHomePageCommand and SearchWebCommand are now used the same way.
  • Renamed SearchCommand → SearchWebCommand and SearchPage → SearchWebPage to align filenames and type names.
  • Moved Icons.cs to Properties to consolidate assets.
  • Renamed WebSearchShortcutItem → WebSearchShortcutDataEntry to better reflect the data role.
  • Refactored SearchWebPage for easier readability.
  • Renamed functions in WebSearchShortcutCommandsProvider for clearer intent.
  • Refactored Suggestions for easier use and understanding.
  • Reduced visibility where possible: changed public to internal/private.
  • Replaced List<T> with T[] (internal immutable snapshots) or IReadOnlyList<T> (API boundaries) where mutation isn’t required.
  • BrowserDiscovery: replaced double-checked locking with built-in Lazy<T> cache; reload now supports an optional warm mode.

Fixes

  • Storage: WriteToFile now respects the caller-provided path.
  • Standardized use of Icons.Search in OpenHomePageCommand and SearchWebCommand, removing hardcoded icons.
  • BrowserDiscovery: Using built-in Lazy<T> fixes a potential memory-visibility issue where _isLoaded could be observed before _cachedBrowsers due to CPU/JIT reordering, ensuring readers never see stale/empty data after initialization.

Chore

  • Removed outdated comments, code, and parameters; formatted the codebase.

@Testudinidae
Copy link
Contributor Author

Consider renaming WebSearchShortcutItem to WebSearchShortcutEntry (or something else), since it’s not a UI element and is more like a data record.
Do you think this rename makes sense?

ps. Naming is hard 😅

@Daydreamer-riri
Copy link
Owner

Consider renaming WebSearchShortcutItem to WebSearchShortcutEntry (or something else), since it’s not a UI element and is more like a data record. Do you think this rename makes sense?

ps. Naming is hard 😅

That makes sense. Thanks!

@Testudinidae Testudinidae marked this pull request as draft August 14, 2025 11:14
@Testudinidae Testudinidae force-pushed the refactor/consistency branch 2 times, most recently from 07d6dab to 4f113e9 Compare August 14, 2025 12:56
@Testudinidae Testudinidae force-pushed the refactor/consistency branch 3 times, most recently from ade893f to 14c4fc2 Compare August 15, 2025 01:54
@Testudinidae Testudinidae force-pushed the refactor/consistency branch 4 times, most recently from c414a82 to 3dd8082 Compare August 16, 2025 06:44
@Testudinidae Testudinidae marked this pull request as ready for review August 16, 2025 10:39
@Testudinidae Testudinidae changed the title refactor: rename something and unify OpenHomePage logic with SearchWebCommand refactor Aug 16, 2025
@Testudinidae Testudinidae marked this pull request as draft August 17, 2025 01:39
@Testudinidae Testudinidae marked this pull request as ready for review August 17, 2025 03:02
@Testudinidae Testudinidae marked this pull request as draft August 17, 2025 11:27
@Testudinidae Testudinidae marked this pull request as ready for review August 17, 2025 12:06
@Testudinidae
Copy link
Contributor Author

Ready... hopefully for real this time.

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.

Pull Request Overview

This refactoring PR improves code quality through better naming conventions, cleaner APIs, and enhanced maintainability. The changes focus on making the codebase more consistent and readable while maintaining all existing functionality.

  • Renamed core classes and methods to better reflect their purpose (e.g., WebSearchShortcutItemWebSearchShortcutDataEntry, SearchPageSearchWebPage)
  • Consolidated suggestion providers into a unified registry system with improved API design
  • Enhanced browser discovery with thread-safe lazy initialization replacing manual double-checked locking

Reviewed Changes

Copilot reviewed 39 out of 40 changed files in this pull request and generated no comments.

Show a summary per file
File Description
WebSearchShortcutItem.cs Removed old data model class
WebSearchShortcutDataEntry.cs New data model with better naming and added GetHomePageUrl method
WebSearchShortcutCommandsProvider.cs Refactored command provider with cleaner method names and improved organization
SuggestionsProviders/*.cs Moved and updated suggestion providers with consistent interface implementation
Suggestion.cs Refactored suggestions system into registry pattern with improved API
Storage.cs Fixed path handling bug and updated to use new data model
SearchWebPage.cs New search page implementation replacing SearchPage.cs
Commands/*.cs Updated commands to use new data model and consistent icon usage
Properties/Icons.cs Moved to Properties namespace and reordered for consistency
Files not reviewed (1)
  • CmdPalWebSearchShortcut/WebSearchShortcut/Properties/Resources.Designer.cs: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Daydreamer-riri
Copy link
Owner

Thank you very much for your contribution! Initially, this project was just a personal project, and many parts were not written meticulously (also, I'm just a beginner in dotnet, with my main development language being TypeScript), so there are many rough areas in the project code. This PR has addressed these issues! Thanks again for your contribution.

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.

2 participants