Skip to content

refactor: add unique ID field to ButtonConfig for identity tracking#102

Merged
kubrickcode merged 1 commit into
mainfrom
develop/shlee/81
Nov 19, 2025
Merged

refactor: add unique ID field to ButtonConfig for identity tracking#102
kubrickcode merged 1 commit into
mainfrom
develop/shlee/81

Conversation

@kubrickcode

Copy link
Copy Markdown
Owner

Added mandatory id field to ButtonConfig to enable unique identification of each button and group.

  • Added id: string field to ButtonConfig type
  • Implemented ID auto-generation utilities (ensureId, ensureIdsInArray)
  • Auto-assign IDs when loading existing config data in ConfigReader
  • Generate UUIDs automatically when creating new buttons/groups in webview components and hooks
  • Added id field to all test cases to ensure type safety

fix #81

@github-actions github-actions Bot added the refactor Refactoring code label Nov 19, 2025
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @kubrickcode, 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 refactors the ButtonConfig structure by introducing a mandatory unique ID field. This change is crucial for reliably tracking and managing individual buttons and command groups throughout the application, especially in dynamic UI contexts like the webview and configuration management. It ensures that every configurable item has a stable identifier, which will facilitate future features requiring persistent referencing or reordering of commands.

Highlights

  • Mandatory ID Field: A new mandatory id: string field has been added to the ButtonConfig type to ensure unique identification for each button and group.
  • ID Auto-Generation: Utilities (ensureId, ensureIdsInArray) have been implemented to automatically generate UUIDs for ButtonConfig objects if an ID is not already present, including recursively for nested groups.
  • Configuration Loading Integration: The ConfigReader now automatically assigns unique IDs to buttons and groups when loading existing configuration data, ensuring all loaded items have an identifier.
  • Webview Component Updates: New buttons and groups created within the webview components and hooks will now automatically generate UUIDs, improving consistency and tracking in the UI.
  • Test Coverage Expansion: All relevant test cases have been updated to include the new id field, ensuring type safety and correct behavior of ID generation and preservation across the application.
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.

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

Copy link
Copy Markdown

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 effectively introduces a mandatory id field to ButtonConfig for unique identification, which is a great improvement for tracking and managing buttons, especially for features like reordering. The implementation is thorough, covering data migration for existing configs, UI updates for creating new items, and comprehensive test updates. The move to use unique IDs instead of array indices for keys and sorting logic is a solid refactoring choice. I've identified a key area for improvement regarding type safety in the new ensure-id utility, which will make the implementation more robust and align better with TypeScript's principles. I also have a minor suggestion about code organization to prevent potential issues in the future.

Comment thread src/shared/utils/ensure-id.ts Outdated
Comment thread src/internal/utils/ensure-id.ts
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 introduces a mandatory id field to the ButtonConfig type for unique identification, which is a great improvement for tracking and managing buttons. The implementation correctly handles auto-generation of IDs for new and existing configurations, including nested groups. The updates to the React components to use these stable IDs for keys and sorting logic are well-executed and follow best practices. I've found one area for improvement regarding type safety in the new ensure-id.ts utility, where the type for configurations with optional IDs isn't fully recursive. My suggestion addresses this to make the new logic more robust. Overall, this is a solid refactoring that enhances the extension's architecture.

Comment thread src/internal/utils/ensure-id.ts Outdated
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 is a well-executed refactoring that introduces a mandatory id field to the ButtonConfig type for unique identification. The changes are comprehensive, touching the type definitions, data loading logic to ensure backward compatibility, UI components, and hooks to leverage the new id for more robust state management. The test suite has also been thoroughly updated to reflect these changes. I have one suggestion to improve the implementation of the new ensureId utility to better align with the project's immutability standards.

Comment thread src/internal/utils/ensure-id.ts
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 introduces a mandatory id field to the ButtonConfig type to enable unique identification of buttons. The changes are well-implemented across the extension backend, the webview frontend, and the test suite. The addition of ensureId utilities to automatically assign IDs to existing or new configurations is a robust solution. The test coverage for the new functionality is thorough.

My review includes a few suggestions to enhance type safety and code clarity, particularly around handling data from external configuration sources and a minor refactoring opportunity in the new utility function. Overall, this is a solid refactoring that improves the maintainability and stability of the application.

Comment thread src/internal/adapters.ts
Comment thread src/internal/utils/ensure-id.ts Outdated
Comment thread src/internal/utils/ensure-id.ts Outdated
Added mandatory id field to ButtonConfig to enable unique identification of each button and group.

- Added id: string field to ButtonConfig type
- Implemented ID auto-generation utilities (ensureId, ensureIdsInArray)
- Auto-assign IDs when loading existing config data in ConfigReader
- Generate UUIDs automatically when creating new buttons/groups in webview components and hooks
- Added id field to all test cases to ensure type safety

fix #81
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 is a great refactoring that introduces a mandatory id field to ButtonConfig. This significantly improves identity tracking, especially for the React components, by enabling stable keys for lists and more robust drag-and-drop functionality. The implementation is solid, with utility functions to ensure IDs are always present, and comprehensive updates to tests. I've found a couple of minor style guide violations that should be addressed for consistency. Overall, excellent work on improving the codebase's robustness.

Comment thread src/internal/utils/ensure-id.ts
Comment thread src/tests/utils-ensure-id.spec.ts
@kubrickcode kubrickcode merged commit e18d7bd into main Nov 19, 2025
5 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/81 branch November 19, 2025 14:46
@kubrickcode

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 0.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Web-view Array Index Key issue

1 participant