Skip to content

fix(models): resolve vision capability from modalities when explicit field is absent#1542

Merged
looplj merged 1 commit into
looplj:unstablefrom
djdembeck:fix/model-vision-resolution
Apr 30, 2026
Merged

fix(models): resolve vision capability from modalities when explicit field is absent#1542
looplj merged 1 commit into
looplj:unstablefrom
djdembeck:fix/model-vision-resolution

Conversation

@djdembeck

Copy link
Copy Markdown
Contributor

Summary

Fix vision capability resolution for models that have image modality but lack explicit vision field. This ensures consistent vision detection across the codebase.

Spirit/Intent

Enable automatic vision capability detection from input modalities when explicit vision field is missing, preventing models with image support from being incorrectly marked as non-vision.

Key Changes

  • Added resolveVision helper in providers.schema.ts that checks explicit vision field first, then falls back to checking if 'image' is in input modalities
  • Updated models-action-dialog.tsx to use resolveVision instead of direct vision field access
  • Updated models-batch-create-dialog.tsx to use resolveVision instead of attachment-based fallback

Risks

Low risk - backward compatible change that preserves explicit vision field when present, only adds fallback behavior when absent.

@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces resolveVision, a small helper that canonicalises vision detection across two dialogs by checking model.vision first, then falling back to modalities.input.includes('image'). The most meaningful fix is in models-batch-create-dialog.tsx, which previously used attachment as a proxy for vision capability — a semantically incorrect substitution now replaced with the proper modality check.

Confidence Score: 5/5

Safe to merge — backward-compatible fix with no P0/P1 findings.

All changes are additive and backward-compatible. The helper correctly preserves explicit vision values and only adds fallback logic when the field is absent. No security, data-integrity, or runtime correctness issues were identified.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/features/models/data/providers.schema.ts Adds resolveVision helper that returns explicit vision field when present, otherwise checks if 'image' is in modalities.input; clean, backward-compatible logic.
frontend/src/features/models/components/models-action-dialog.tsx Replaces direct selectedModel.vision (which could be undefined) with resolveVision(selectedModel), ensuring a boolean is always passed to the form.
frontend/src/features/models/components/models-batch-create-dialog.tsx Replaces the semantically incorrect `attachment

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects a model] --> B{resolveVision called}
    B --> C{model.vision !== undefined?}
    C -- Yes --> D[Return model.vision]
    C -- No --> E{modalities?.input includes 'image'?}
    E -- Yes --> F[Return true]
    E -- No --> G[Return false]

    D --> H[Set vision field in form]
    F --> H
    G --> H

    subgraph models-action-dialog.tsx
        I[handleModelIdChange] --> B
    end

    subgraph models-batch-create-dialog.tsx
        J[handleModelIdChange] --> B
    end
Loading

Reviews (3): Last reviewed commit: "fix(models): resolve vision capability f..." | Re-trigger Greptile

Comment thread frontend/src/features/models/data/providers.schema.ts Outdated
@djdembeck djdembeck force-pushed the fix/model-vision-resolution branch from 5228188 to 100773f Compare April 29, 2026 19:18

@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 resolveVision utility function to centralize the logic for determining vision support based on model properties or input modalities. This function is integrated into the model action and batch creation dialogs to ensure consistent behavior. Feedback suggests simplifying the resolveVision implementation using optional chaining to avoid unnecessary array creation and improve readability.

I am having trouble creating individual review comments. Click here to see my feedback.

frontend/src/features/models/data/providers.schema.ts (69-72)

medium

The resolveVision function can be simplified using optional chaining and the nullish coalescing operator for better readability. This approach avoids creating an intermediate empty array when modalities or input is missing.

export function resolveVision(model: ProviderModel): boolean {
  if (model.vision !== undefined) return model.vision;
  return !!model.modalities?.input?.includes('image');
}

…field is absent

- Add resolveVision() helper that infers vision=true from
  modalities.input containing 'image' when the explicit vision
  field is undefined (affects ~150 models in providers.json)
- Fix batch-create-dialog: was incorrectly reading attachment
  instead of vision (attachment != vision capability)
- Fix action-dialog: was reading raw .vision which is undefined
  for models that lack the explicit field
@djdembeck djdembeck force-pushed the fix/model-vision-resolution branch from 100773f to 8fe0202 Compare April 29, 2026 19:22
@looplj looplj merged commit 295db39 into looplj:unstable Apr 30, 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.

2 participants