Skip to content

fix: max model association priority, close #1507#1581

Merged
looplj merged 1 commit into
unstablefrom
dev-tmp
May 1, 2026
Merged

fix: max model association priority, close #1507#1581
looplj merged 1 commit into
unstablefrom
dev-tmp

Conversation

@looplj

@looplj looplj commented May 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

@greptile-apps

greptile-apps Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extracts the hardcoded maximum association priority value (10) into a named constant MAX_ASSOCIATION_PRIORITY and applies it consistently across the Zod schema validation (including the error message), the <Input> max attribute, and the onChange clamping logic.

Confidence Score: 5/5

Safe to merge — all hardcoded occurrences of 10 have been replaced with the new constant, including the previously flagged error message.

The change is a clean, focused refactor with no logic changes. All three usage sites (schema validation, error message, and input clamping) are correctly updated. The prior concern about the hardcoded value in the error message has been addressed in this PR.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/features/models/components/models-association-dialog.tsx Introduces MAX_ASSOCIATION_PRIORITY constant and replaces all three hardcoded occurrences of 10 — schema max, input max attr, and onChange clamp — including the error message string.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User types priority value] --> B[onChange handler]
    B --> C["Math.max(0, Math.min(MAX_ASSOCIATION_PRIORITY, value))"]
    C --> D[Clamped value written to form state]
    D --> E[Zod schema validation]
    E --> F{".min(0).max(MAX_ASSOCIATION_PRIORITY)"}
    F -->|valid| G[Form submits]
    F -->|invalid| H["Error: Priority cannot exceed MAX_ASSOCIATION_PRIORITY"]
Loading

Reviews (2): Last reviewed commit: "fix: max model association priority, clo..." | Re-trigger Greptile

Comment thread frontend/src/features/models/components/models-association-dialog.tsx Outdated

@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 a MAX_ASSOCIATION_PRIORITY constant to the models-association-dialog.tsx component, updating the Zod validation schema and the UI input logic to use this centralized value. While the logic was updated, the validation error message in the schema remains hardcoded to "10" and should be updated to use the constant to ensure consistency.

z.object({
type: z.enum(['channel_model', 'channel_regex', 'model', 'regex', 'channel_tags_model', 'channel_tags_regex']),
priority: z.number().min(0, 'Priority must be at least 0').max(10, 'Priority cannot exceed 10'),
priority: z.number().min(0, 'Priority must be at least 0').max(MAX_ASSOCIATION_PRIORITY, 'Priority cannot exceed 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.

medium

The error message for the max validation is still hardcoded to "10". It should use the MAX_ASSOCIATION_PRIORITY constant to ensure consistency if the limit is changed in the future.

Suggested change
priority: z.number().min(0, 'Priority must be at least 0').max(MAX_ASSOCIATION_PRIORITY, 'Priority cannot exceed 10'),
priority: z.number().min(0, 'Priority must be at least 0').max(MAX_ASSOCIATION_PRIORITY, `Priority cannot exceed ${MAX_ASSOCIATION_PRIORITY}`),

@looplj looplj merged commit aa95b16 into unstable May 1, 2026
4 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