Problems: auto-fix & problem panel (#541)
Test cases: - [x] create-ts-errors - [x] with auto-fix - [x] without auto-fix - [x] create-unfixable-ts-errors - [x] manually edit file & click recheck - [x] fix all - [x] delete and rename case THINGS - [x] error handling for checkProblems isn't working as expected - [x] make sure it works for both default templates (add tests) - [x] fix bad animation - [x] change file context (prompt/files) IF everything passes in Windows AND defensive try catch... then enable by default - [x] enable auto-fix by default
This commit is contained in:
@@ -25,6 +25,55 @@ export const createChatCompletionHandler =
|
||||
|
||||
let messageContent = CANNED_MESSAGE;
|
||||
|
||||
// TS auto-fix prefixes
|
||||
if (
|
||||
lastMessage &&
|
||||
typeof lastMessage.content === "string" &&
|
||||
lastMessage.content.startsWith(
|
||||
"Fix these 2 TypeScript compile-time error",
|
||||
)
|
||||
) {
|
||||
// Fix errors in create-ts-errors.md and introduce a new error
|
||||
messageContent = `
|
||||
<dyad-write path="src/bad-file.ts" description="Fix 2 errors and introduce a new error.">
|
||||
// Import doesn't exist
|
||||
// import NonExistentClass from 'non-existent-class';
|
||||
|
||||
|
||||
const x = new Object();
|
||||
x.nonExistentMethod2();
|
||||
</dyad-write>
|
||||
|
||||
`;
|
||||
}
|
||||
if (
|
||||
lastMessage &&
|
||||
typeof lastMessage.content === "string" &&
|
||||
lastMessage.content.startsWith(
|
||||
"Fix these 1 TypeScript compile-time error",
|
||||
)
|
||||
) {
|
||||
// Fix errors in create-ts-errors.md and introduce a new error
|
||||
messageContent = `
|
||||
<dyad-write path="src/bad-file.ts" description="Fix remaining error.">
|
||||
// Import doesn't exist
|
||||
// import NonExistentClass from 'non-existent-class';
|
||||
|
||||
|
||||
const x = new Object();
|
||||
x.toString(); // replaced with existing method
|
||||
</dyad-write>
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
if (
|
||||
lastMessage &&
|
||||
typeof lastMessage.content === "string" &&
|
||||
lastMessage.content.includes("TypeScript compile-time error")
|
||||
) {
|
||||
messageContent += "\n\n" + generateDump(req);
|
||||
}
|
||||
if (
|
||||
lastMessage &&
|
||||
typeof lastMessage.content === "string" &&
|
||||
|
||||
Reference in New Issue
Block a user