From 410a4e3d3b1d320d5568d99768dceef9702c0113 Mon Sep 17 00:00:00 2001 From: Sanjiv Das Date: Fri, 8 Aug 2025 06:43:55 -0700 Subject: [PATCH 1/2] Update model-id-input.tsx --- .../components/settings/model-id-input.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/jupyter-ai/src/components/settings/model-id-input.tsx b/packages/jupyter-ai/src/components/settings/model-id-input.tsx index 888788d0b..2d86eb45a 100644 --- a/packages/jupyter-ai/src/components/settings/model-id-input.tsx +++ b/packages/jupyter-ai/src/components/settings/model-id-input.tsx @@ -1,9 +1,31 @@ import React, { useState, useEffect } from 'react'; -import { Autocomplete, TextField, Button, Box } from '@mui/material'; +import { Autocomplete, TextField, Button, Box, Typography } from '@mui/material'; import { AiService } from '../../handler'; import { useStackingAlert } from '../mui-extras/stacking-alert'; import Save from '@mui/icons-material/Save'; +/** + * Highlights matched substrings in a given text by wrapping them in bold tags. + */ +const highlightMatches = (text: string, inputValue: string) => { + if (!inputValue) return text; + + const parts = text.split(new RegExp(`(${inputValue})`, 'gi')); + return ( + + {parts.map((part, index) => + part.toLowerCase() === inputValue.toLowerCase() ? ( + + {part} + + ) : ( + part + ) + )} + + ); +}; + export type ModelIdInputProps = { /** * The label of the model ID input field. @@ -129,13 +151,15 @@ export function ModelIdInput(props: ModelIdInputProps): JSX.Element { return ( + model.toLowerCase().includes(input.toLowerCase()) + )} value={input} freeSolo autoSelect loading={loading} fullWidth={props.fullWidth} - onInputChange={(e, newValue, r) => { + onInputChange={(_, newValue) => { // This condition prevents whitespace from being inserted in the model // ID by accident. if (newValue !== null && !newValue.includes(' ')) { @@ -150,6 +174,11 @@ export function ModelIdInput(props: ModelIdInputProps): JSX.Element { fullWidth={props.fullWidth ?? true} /> )} + renderOption={(props, option) => ( +
  • + {highlightMatches(option, input)} +
  • + )} />