Skip to content

Commit 40b46c9

Browse files
ELin2025claude
andcommitted
fix(frontend): handle search stream errors and fix clear model value
- Catch HTTP errors inside switchMap so search stream survives failures - Use empty string instead of null when clearing model selection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent df1947d commit 40b46c9

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

frontend/src/app/workspace/component/hugging-face/hugging-face.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
nzType="close"
133133
nzTheme="outline"
134134
style="cursor: pointer; color: #999; margin-left: 4px"
135-
(click)="formControl.setValue(null)"></i>
135+
(click)="formControl.setValue('')"></i>
136136
</div>
137137

138138
<!-- No results message -->

frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { NzSpinModule } from "ng-zorro-antd/spin";
2828
import { NzButtonModule } from "ng-zorro-antd/button";
2929
import { NzIconModule } from "ng-zorro-antd/icon";
3030
import { AppSettings } from "../../../common/app-setting";
31-
import { Subject, Subscription } from "rxjs";
32-
import { debounceTime, finalize, switchMap, takeUntil } from "rxjs/operators";
31+
import { of, Subject, Subscription } from "rxjs";
32+
import { catchError, debounceTime, finalize, switchMap, takeUntil } from "rxjs/operators";
3333

3434
export interface HuggingFaceModelOption {
3535
id: string;
@@ -460,23 +460,28 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
460460
const tag = this.selectedTaskTag || "text-generation";
461461
this.searchLoading = true;
462462
this.cdr.detectChanges();
463-
return this.http.get<HuggingFaceModelOption[]>(
464-
`${AppSettings.getApiEndpoint()}/huggingface/models?task=${encodeURIComponent(tag)}&search=${encodeURIComponent(query)}`
465-
);
463+
return this.http
464+
.get<HuggingFaceModelOption[]>(
465+
`${AppSettings.getApiEndpoint()}/huggingface/models?task=${encodeURIComponent(tag)}&search=${encodeURIComponent(query)}`
466+
)
467+
.pipe(
468+
catchError((err: unknown) => {
469+
console.error("Server-side search failed:", err);
470+
this.searchLoading = false;
471+
this.cdr.detectChanges();
472+
return of(null);
473+
})
474+
);
466475
}),
467476
takeUntil(this.destroy$)
468477
)
469478
.subscribe({
470479
next: models => {
480+
if (models === null) return;
471481
this.searchLoading = false;
472482
this.filteredModels = models;
473483
this.goToPage(0);
474484
},
475-
error: (err: unknown) => {
476-
console.error("Server-side search failed:", err);
477-
this.searchLoading = false;
478-
this.cdr.detectChanges();
479-
},
480485
});
481486
}
482487

0 commit comments

Comments
 (0)