feat: Toggle category annotations visibility#7
Conversation
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @jellydn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience of the Code Notes extension by introducing granular control over inline annotation visibility. Users can now selectively display or hide annotation categories like 'bug' or 'question', reducing visual clutter and allowing them to focus on specific types of feedback without disabling all annotations. This feature is accessible via a new command palette entry and maintains visibility state throughout the current session. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully introduces a valuable feature for toggling the visibility of category annotations, which will improve the user experience by reducing visual clutter. The implementation is logical and covers all the requirements outlined in the PR description. My review includes a significant suggestion to refactor the way comment categories are defined. Currently, they are duplicated in several places, which could lead to maintenance issues. By centralizing the category definitions, the code will become more robust and easier to update in the future.
| const inlineDecorationTypes: Map<CommentCategory, TextEditorDecorationType> = new Map() | ||
| const backgroundDecorationTypes: Map<CommentCategory, TextEditorDecorationType> = new Map() | ||
|
|
||
| const ALL_CATEGORIES: CommentCategory[] = ['bug', 'question', 'suggestion', 'nitpick', 'note'] |
There was a problem hiding this comment.
This new ALL_CATEGORIES constant duplicates the list of categories that already exists in src/commands.ts (in CATEGORY_ITEMS and the new TOGGLE_CATEGORY_ITEMS). This makes the code harder to maintain, as any changes to categories must be manually synchronized across multiple files.
To create a single source of truth, I suggest defining a more comprehensive category structure here and exporting it. This file is a good location for it since commands.ts already depends on decorations.ts, avoiding circular dependencies.
You could then use this structure to derive ALL_CATEGORIES and also refactor src/commands.ts to use it, eliminating duplication.
| const ALL_CATEGORIES: CommentCategory[] = ['bug', 'question', 'suggestion', 'nitpick', 'note'] | |
| export const CATEGORIES = [ | |
| { value: 'bug', label: 'Bug' }, | |
| { value: 'question', label: 'Question' }, | |
| { value: 'suggestion', label: 'Suggestion' }, | |
| { value: 'nitpick', label: 'Nitpick' }, | |
| { value: 'note', label: 'Note' }, | |
| ] as const; | |
| const ALL_CATEGORIES: CommentCategory[] = CATEGORIES.map(c => c.value); |
| const TOGGLE_CATEGORY_ITEMS: { label: string, value: CommentCategory, description: string }[] = [ | ||
| { label: 'Bug', value: 'bug', description: '' }, | ||
| { label: 'Question', value: 'question', description: '' }, | ||
| { label: 'Suggestion', value: 'suggestion', description: '' }, | ||
| { label: 'Nitpick', value: 'nitpick', description: '' }, | ||
| { label: 'Note', value: 'note', description: '' }, | ||
| ] |
There was a problem hiding this comment.
This TOGGLE_CATEGORY_ITEMS constant is another duplication of the category list.
Following my suggestion in src/decorations.ts to create a central CATEGORIES constant, you could import it here and generate the quick pick items dynamically inside toggleCategoryAnnotations, removing the need for this constant.
For example:
// import { CATEGORIES } from './decorations';
// ... inside toggleCategoryAnnotations()
const items = [
// ... 'Show All' and 'Hide All' items
...CATEGORIES.map(item => ({
label: isCategoryVisible(item.value) ? `$(check) ${item.label}` : item.label,
value: item.value,
description: isCategoryVisible(item.value) ? 'Visible' : 'Hidden',
})),
];This would remove this duplicated constant and make the code more maintainable. You could then apply a similar pattern to the CATEGORY_ITEMS constant in this file to eliminate all category duplication.
chore: fix lint
c08a828 to
c16df85
Compare
What
Adds the ability to toggle inline annotation visibility by category (TODOs, FIXMEs, etc.) in the Code Notes extension.
Why
Users often want to focus on specific types of annotations rather than seeing all of them at once. This feature allows selective visibility control per category, improving the editing experience.
How
src/commands.tssrc/decorations.tstoggleCategoryAnnotationscommand with quick pick UI for category selectionChanges
codeNotes.toggleCategoryAnnotations