Skip to content

Commit

Permalink
Merge pull request #3009 from the-deep/fix/show-error-if-no-recommend…
Browse files Browse the repository at this point in the history
…ations

Show error in case of no recommendations in assist popup
  • Loading branch information
shreeyash07 authored Dec 11, 2024
2 parents ba6649f + 1c89ec7 commit 991008d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/components/LeftPaneEntries/AssistItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function AssistItem(props: Props) {
error,
} = useForm(schema, emptyEntry);

const [messageText] = useState<string | undefined>();
const [messageText, setMessageText] = useState<string | undefined>();

const [draftEntryId, setDraftEntryId] = useState<string | undefined>(undefined);
// FIXME: randomId is used to create different query variables after each poll
Expand All @@ -249,7 +249,7 @@ function AssistItem(props: Props) {
const [recommendations, setRecommendations] = useState<PartialAttributeType[]>();

const handleTagsFetch = useCallback((recommendedTags: ModelTagsType) => {
const newAttributes = allWidgets?.map((widget) => {
const newAttributes = allWidgets.map((widget) => {
if (widget.widgetId === 'MATRIX1D') {
return createMatrix1dAttrFromTags(
recommendedTags[widget.key] as Matrix1dValue,
Expand All @@ -265,6 +265,11 @@ function AssistItem(props: Props) {
return undefined;
}).filter(isDefined);

if (newAttributes.length < 1) {
setIsErrored(true);
setMessageText('DEEP could not provide any recommendations for the selected text.');
}

setRecommendations(newAttributes);
setValue(
(oldEntry) => {
Expand Down Expand Up @@ -325,6 +330,8 @@ function AssistItem(props: Props) {

const modelTags = result?.tags?.modelTags;
if (!isValidObject(modelTags)) {
setIsErrored(true);
setMessageText('DEEP could not provide any recommendations for the selected text.');
return;
}

Expand Down

0 comments on commit 991008d

Please sign in to comment.