Skip to content

Conversation

@Shironex
Copy link
Collaborator

@Shironex Shironex commented Jan 11, 2026

Summary

Refactor the "Enhance with AI" feature to eliminate code duplication and improve maintainability by extracting shared components following DRY principles and clean code guidelines.

Problem

The "Enhance with AI" feature and its history UI were duplicated across three dialogs:

  • add-feature-dialog.tsx (~175 lines duplicated)
  • edit-feature-dialog.tsx (~170 lines duplicated)

This violated the DRY principle and made maintenance difficult.

Solution

Created a dedicated shared/enhancement/ folder with reusable components:

New Components

  1. enhancement-constants.ts

    • EnhancementMode type
    • ENHANCEMENT_MODE_LABELS constant
    • ENHANCEMENT_MODE_DESCRIPTIONS constant
  2. enhance-with-ai.tsx

    • Reusable AI enhancement component
    • Manages state internally (isEnhancing, mode, collapsible)
    • Model override support
    • History tracking callback
  3. enhancement-history-button.tsx

    • Generic history button component
    • Works with any history entry type
    • Popover UI with version browsing
    • Restore functionality
    • Source labels (Original/Enhanced/Edited)

Refactored Dialogs

  • add-feature-dialog.tsx: -173 lines (-26%)
  • edit-feature-dialog.tsx: -159 lines (-22%)

Additional Improvements

  • Added history tracking to add-feature-dialog for consistency
  • Fixed hardcoded enhancement labels in edit-feature-dialog
  • Improved code organization following folder-pattern.md
  • follow-up-dialog.tsx now also include the same feature as 2 other dialogs

Extract all "Enhance with AI" functionality into reusable shared components
following DRY principles and clean code guidelines.

Changes:
- Create shared/enhancement/ folder for related functionality
- Extract EnhanceWithAI component (AI enhancement with model override)
- Extract EnhancementHistoryButton component (version history UI)
- Extract enhancement constants and types
- Refactor add-feature-dialog.tsx to use shared components
- Refactor edit-feature-dialog.tsx to use shared components
- Refactor follow-up-dialog.tsx to use shared components
- Add history tracking to add-feature-dialog for consistency

Benefits:
- Eliminated ~527 lines of duplicated code
- Single source of truth for enhancement logic
- Consistent UX across all dialogs
- Easier maintenance and extensibility
- Better code organization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Shironex Shironex self-assigned this Jan 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shironex, 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 undertakes a significant refactoring of the 'Enhance with AI' feature, moving its implementation into a set of dedicated, reusable shared components. This change aims to drastically reduce code duplication across multiple dialogs, thereby enhancing the overall maintainability and consistency of the application's AI enhancement user interface. The update also standardizes and extends history tracking for AI-generated content across these dialogs.

Highlights

  • Refactor "Enhance with AI" Feature: The core 'Enhance with AI' functionality and its associated history UI have been extracted into a new shared/enhancement/ folder to eliminate code duplication and improve maintainability.
  • New Shared Components: Three new reusable components were created: enhance-with-ai.tsx for the AI enhancement UI, enhancement-history-button.tsx for generic history tracking and restoration, and enhancement-constants.ts for shared types and labels.
  • Significant Code Reduction: The refactoring led to substantial line reductions in add-feature-dialog.tsx (-173 lines), edit-feature-dialog.tsx (-159 lines), and follow-up-dialog.tsx (-195 lines), totaling approximately 527 lines of removed duplication.
  • Enhanced History Tracking: History tracking for AI-enhanced descriptions was added to add-feature-dialog for consistency, and the follow-up-dialog now also supports prompt history using the new shared components.
  • Improved Consistency and Maintainability: By centralizing the logic, all dialogs now share the same AI enhancement and history UX, making future changes easier to implement and ensuring a consistent user experience.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Shironex Shironex added Enhancement Improvements to existing functionality or UI. Testers-Requested Request for others to test an enhancement or bug fix/etc. Refactor A complete logic rewrite is requested or being performed for an issue. Do Not Merge Use this label if something should not be merged. labels Jan 11, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent refactoring that successfully extracts the 'Enhance with AI' functionality into shared, reusable components, significantly reducing code duplication and improving maintainability. The new components in shared/enhancement/ are well-designed and follow DRY principles. The overall code quality is high. I've identified a minor functional regression where thinkingLevel is no longer passed during enhancement, and a couple of opportunities to further improve the maintainability and performance of the new shared components. Overall, great work on cleaning up the codebase.

Address three issues identified in code review:

1. Fix missing thinkingLevel parameter (Critical)
   - Added thinkingLevel parameter to enhance API call
   - Updated electron.ts type definition to match http-api-client
   - Fixes functional regression in Claude model enhancement

2. Refactor dropdown menu to use constants dynamically
   - Changed hardcoded DropdownMenuItem components to dynamic generation
   - Now iterates over ENHANCEMENT_MODE_LABELS object
   - Ensures automatic sync when new modes are added
   - Eliminates manual UI updates for new enhancement modes

3. Optimize array reversal performance
   - Added useMemo hook to memoize reversed history array
   - Prevents creating new array on every render
   - Improves performance with lengthy histories

All TypeScript errors resolved. Build verified.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Shironex
Copy link
Collaborator Author

/gemini please re-check after latest commits

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent refactoring that significantly improves code quality by extracting the 'Enhance with AI' functionality into reusable shared components. The changes effectively reduce code duplication in add-feature-dialog.tsx and edit-feature-dialog.tsx, and extend the functionality to follow-up-dialog.tsx, which is a great enhancement. The new shared components in shared/enhancement/ are well-structured and follow DRY principles.

My review includes a few suggestions to further improve consistency and maintainability, such as using the new shared types to eliminate remaining hardcoded values and ensuring new interfaces extend the shared base types. Overall, this is a very solid pull request.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does an excellent job of refactoring the 'Enhance with AI' feature into shared, reusable components, adhering to DRY principles and improving code maintainability. The new components are well-structured, and the feature has been consistently applied across the add-feature-dialog, edit-feature-dialog, and follow-up-dialog. My review includes a fix for a potential UI bug in the new history component and suggestions to enhance the new version history functionality to make it more robust and user-friendly by tracking manual edits.

Shironex and others added 2 commits January 11, 2026 15:27
- Add fallback for unknown enhancement modes in history button to prevent "Enhanced (undefined)" UI bug
- Move DescriptionHistoryEntry interface to top level in add-feature-dialog
- Import and use EnhancementMode type in edit-feature-dialog to eliminate hardcoded types
- Make FollowUpHistoryEntry extend BaseHistoryEntry for consistency

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Introduced a new parameter `preEnhancementDescription` to capture the original description before enhancements.
- Updated the `update` method in `FeatureLoader` to handle the new parameter and maintain a history of original descriptions.
- Enhanced UI components to support tracking and restoring pre-enhancement descriptions across various dialogs.
- Improved history management in `AddFeatureDialog`, `EditFeatureDialog`, and `FollowUpDialog` to include original text for better user experience.

This change enhances the ability to revert to previous descriptions, improving the overall functionality of the feature enhancement process.
@Shironex Shironex merged commit a266d85 into v0.10.0rc Jan 11, 2026
4 of 6 checks passed
@Shironex Shironex deleted the refactor/extract-enhance-with-ai-shared-components branch January 11, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Use this label if something should not be merged. Enhancement Improvements to existing functionality or UI. Refactor A complete logic rewrite is requested or being performed for an issue. Testers-Requested Request for others to test an enhancement or bug fix/etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants