Skip to content

Commit 04dcb17

Browse files
committed
Autofixing errors whenever there is an error generated
1 parent f05a464 commit 04dcb17

File tree

1 file changed

+12
-2
lines changed
  • apps/studio/src/lib/editor/engine/error

1 file changed

+12
-2
lines changed

apps/studio/src/lib/editor/engine/error/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ProjectsManager } from '@/lib/projects';
22
import { type ParsedError, compareErrors } from '@onlook/utility';
3-
import { makeAutoObservable } from 'mobx';
3+
import { autorun, makeAutoObservable } from 'mobx';
44
import type { EditorEngine } from '..';
55

66
export class ErrorManager {
@@ -13,13 +13,23 @@ export class ErrorManager {
1313
private editorEngine: EditorEngine,
1414
private projectsManager: ProjectsManager,
1515
) {
16-
makeAutoObservable(this, {});
16+
makeAutoObservable(this);
17+
18+
autorun(() => {
19+
if (this.shouldAutoFixErrors) {
20+
this.sendFixError();
21+
}
22+
});
1723
}
1824

1925
get errors() {
2026
return [...this.terminalErrors];
2127
}
2228

29+
get shouldAutoFixErrors() {
30+
return this.errors.length > 0 && !this.editorEngine.chat.isWaiting;
31+
}
32+
2333
async sendFixError() {
2434
if (this.errors.length > 0) {
2535
const res = await this.editorEngine.chat.sendFixErrorToAi(this.errors);

0 commit comments

Comments
 (0)