Skip to content

fix: model association priority and ui align#344

Merged
looplj merged 1 commit into
unstablefrom
development
Dec 24, 2025
Merged

fix: model association priority and ui align#344
looplj merged 1 commit into
unstablefrom
development

Conversation

@looplj

@looplj looplj commented Dec 24, 2025

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @looplj, 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 refines the model association functionality by implementing a priority-based system, which dictates the order of model evaluation. It also significantly improves the user experience within the model association dialog through UI alignment adjustments, the introduction of an AutoCompleteSelect for channel selection, and robust input validation. These changes collectively aim to provide users with more precise control over model behavior and a more intuitive configuration interface.

Highlights

  • Model Association Priority System: Introduced a priority field for model associations, allowing users to define the order in which associated models are evaluated. Associations are now sorted by this priority (lower value = higher priority) before processing.
  • Enhanced UI for Model Associations: The model association dialog received several UI/UX improvements, including better alignment of elements, the integration of an AutoCompleteSelect component for channel selection, and clearer validation messages.
  • Robust Association Validation: New validation rules were added to ensure data integrity, such as limiting the priority value between 0 and 100, and restricting the total number of associations to a maximum of 10.
  • Expanded Model Association Types and Schema: The ModelAssociationInput interface and related schemas were updated to include the new priority field and a new 'model' type for global exact matches, alongside changes to GraphQL queries to support these new fields.
  • Improved Localization: Updated English and Chinese localization strings to reflect the new terminology for association types and provide clearer descriptions for the model association feature.
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
Contributor

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 priority for model associations and improves the UI for managing them. The changes include adding validation for priority and association count, sorting associations by priority, and using an auto-complete component for better UX. The code is well-structured, but I've found a couple of areas for improvement. There's a bug in the priority input where the max attribute is inconsistent with the validation logic. I've also suggested improving type safety by avoiding the use of any when processing associations. Overall, these are great enhancements.

<FormControl>
<Input
type='number'
min={0}
max={10}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The max value for the priority input is set to 10, but the form validation schema (max 100) and the onChange handler (clamps to 100) allow values up to 100. This creates an inconsistency where users can't use the input's native controls (e.g., arrow keys) to select a value above 10. This should be updated to 100 to match the validation logic.

Suggested change
max={10}
max={100}

@@ -167,7 +169,8 @@ export function ModelsAssociationDialog() {

const fetchConnections = async () => {
try {
const associations: ModelAssociationInput[] = debouncedAssociations
const sortedDebouncedAssociations = [...debouncedAssociations].sort((a: any, b: any) => (a.priority ?? 0) - (b.priority ?? 0))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using any here reduces type safety and makes the code harder to read and maintain. It's better to use a proper type for the items in debouncedAssociations. You can use the type inferred from your Zod schema and let TypeScript handle type checking. This also makes the sorting logic cleaner as priority is a required number.

Suggested change
const sortedDebouncedAssociations = [...debouncedAssociations].sort((a: any, b: any) => (a.priority ?? 0) - (b.priority ?? 0))
const sortedDebouncedAssociations = [...(debouncedAssociations as AssociationFormData['associations'])].sort((a, b) => a.priority - b.priority)

@looplj looplj merged commit 73d6ed3 into unstable Dec 24, 2025
2 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