Skip to content

Commit df1947d

Browse files
ELin2025claude
andcommitted
fix(frontend): address Copilot review feedback on HuggingFaceComponent
- Fix model polling indefinite loop by detecting cancelled in-flight fetch - Fix CSS class mismatch: hf-tasks-error → hf-error to match SCSS - Remove unused imports in spec file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b37ca09 commit df1947d

3 files changed

Lines changed: 12 additions & 9 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
@@ -36,7 +36,7 @@
3636
<!-- Tasks fetch error (non-blocking: static list is still shown) -->
3737
<div
3838
*ngIf="tasksError && !tasksLoading"
39-
class="hf-tasks-error">
39+
class="hf-error">
4040
<span class="error-text">{{ tasksError }}</span>
4141
<button
4242
nz-button

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import {
21-
HuggingFaceComponent,
22-
HuggingFaceModelOption,
23-
STATIC_TASK_OPTIONS,
24-
invalidateHuggingFaceModelCache,
25-
} from "./hugging-face.component";
20+
import { STATIC_TASK_OPTIONS, invalidateHuggingFaceModelCache } from "./hugging-face.component";
2621

2722
describe("HuggingFaceComponent (unit)", () => {
2823
beforeEach(() => {

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,10 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
332332
// Another instance is already fetching this task — wait for it
333333
if (inFlightByTag.has(tag)) {
334334
this.loading = true;
335-
this.modelPollInterval = setInterval(() => {
335+
if (this.modelPollInterval !== null) clearInterval(this.modelPollInterval);
336+
const poll = setInterval(() => {
336337
if (allModelsByTag.has(tag) || errorByTag.has(tag)) {
337-
clearInterval(this.modelPollInterval!);
338+
clearInterval(poll);
338339
this.modelPollInterval = null;
339340
this.loading = false;
340341
if (allModelsByTag.has(tag)) {
@@ -345,8 +346,15 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
345346
this.errorMessage = errorByTag.get(tag)!;
346347
this.cdr.detectChanges();
347348
}
349+
} else if (!inFlightByTag.has(tag)) {
350+
// Fetch was canceled before populating caches; stop polling and fall back.
351+
clearInterval(poll);
352+
this.modelPollInterval = null;
353+
this.loading = false;
354+
this.cdr.detectChanges();
348355
}
349356
}, 200);
357+
this.modelPollInterval = poll;
350358
return;
351359
}
352360

0 commit comments

Comments
 (0)