Show code snippet in fix problems (#745)
This commit is contained in:
@@ -5,11 +5,34 @@
|
|||||||
- img
|
- img
|
||||||
- text: "src/bad-file.ts Summary: This will get a TypeScript error."
|
- text: "src/bad-file.ts Summary: This will get a TypeScript error."
|
||||||
- paragraph: EOM
|
- paragraph: EOM
|
||||||
|
- img
|
||||||
|
- text: Auto-fix5 problems
|
||||||
|
- img
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- paragraph: More EOM
|
||||||
|
- paragraph: "[[dyad-dump-path=*]]"
|
||||||
|
- img
|
||||||
|
- text: Auto-fix5 problems
|
||||||
|
- img
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- paragraph: More EOM
|
||||||
|
- paragraph: "[[dyad-dump-path=*]]"
|
||||||
- paragraph: "Fix these 3 TypeScript compile-time errors:"
|
- paragraph: "Fix these 3 TypeScript compile-time errors:"
|
||||||
- list:
|
- list:
|
||||||
- listitem: src/bad-file.tsx:2:1 - Cannot find name 'nonExistentFunction1'. (TS2304)
|
- listitem: src/bad-file.tsx:2:1 - Cannot find name 'nonExistentFunction1'. (TS2304)
|
||||||
|
- code: const App = () => <div>Minimal imported app</div>; nonExistentFunction1(); // <-- TypeScript compiler error here nonExistentFunction2();
|
||||||
|
- list:
|
||||||
- listitem: src/bad-file.tsx:3:1 - Cannot find name 'nonExistentFunction2'. (TS2304)
|
- listitem: src/bad-file.tsx:3:1 - Cannot find name 'nonExistentFunction2'. (TS2304)
|
||||||
|
- code: nonExistentFunction1(); nonExistentFunction2(); // <-- TypeScript compiler error here nonExistentFunction3();
|
||||||
|
- list:
|
||||||
- listitem: src/bad-file.tsx:4:1 - Cannot find name 'nonExistentFunction3'. (TS2304)
|
- listitem: src/bad-file.tsx:4:1 - Cannot find name 'nonExistentFunction3'. (TS2304)
|
||||||
|
- code: nonExistentFunction2(); nonExistentFunction3(); // <-- TypeScript compiler error here
|
||||||
- paragraph: Please fix all errors in a concise way.
|
- paragraph: Please fix all errors in a concise way.
|
||||||
- img
|
- img
|
||||||
- text: file1.txt
|
- text: file1.txt
|
||||||
@@ -17,5 +40,23 @@
|
|||||||
- text: file1.txt
|
- text: file1.txt
|
||||||
- paragraph: More EOM
|
- paragraph: More EOM
|
||||||
- paragraph: "[[dyad-dump-path=*]]"
|
- paragraph: "[[dyad-dump-path=*]]"
|
||||||
|
- img
|
||||||
|
- text: Auto-fix3 problems
|
||||||
|
- img
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- paragraph: More EOM
|
||||||
|
- paragraph: "[[dyad-dump-path=*]]"
|
||||||
|
- img
|
||||||
|
- text: Auto-fix3 problems
|
||||||
|
- img
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- img
|
||||||
|
- text: file1.txt
|
||||||
|
- paragraph: More EOM
|
||||||
|
- paragraph: "[[dyad-dump-path=*]]"
|
||||||
- button "Retry":
|
- button "Retry":
|
||||||
- img
|
- img
|
||||||
@@ -3,7 +3,24 @@ role: user
|
|||||||
message: Fix these 3 TypeScript compile-time errors:
|
message: Fix these 3 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.tsx:2:1 - Cannot find name 'nonExistentFunction1'. (TS2304)
|
1. src/bad-file.tsx:2:1 - Cannot find name 'nonExistentFunction1'. (TS2304)
|
||||||
|
```
|
||||||
|
const App = () => <div>Minimal imported app</div>;
|
||||||
|
nonExistentFunction1(); // <-- TypeScript compiler error here
|
||||||
|
nonExistentFunction2();
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.tsx:3:1 - Cannot find name 'nonExistentFunction2'. (TS2304)
|
2. src/bad-file.tsx:3:1 - Cannot find name 'nonExistentFunction2'. (TS2304)
|
||||||
|
```
|
||||||
|
nonExistentFunction1();
|
||||||
|
nonExistentFunction2(); // <-- TypeScript compiler error here
|
||||||
|
nonExistentFunction3();
|
||||||
|
```
|
||||||
|
|
||||||
3. src/bad-file.tsx:4:1 - Cannot find name 'nonExistentFunction3'. (TS2304)
|
3. src/bad-file.tsx:4:1 - Cannot find name 'nonExistentFunction3'. (TS2304)
|
||||||
|
```
|
||||||
|
nonExistentFunction2();
|
||||||
|
nonExistentFunction3(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -417,5 +417,9 @@ role: user
|
|||||||
message: Fix these 1 TypeScript compile-time error:
|
message: Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
||||||
|
```
|
||||||
|
finalMainTsxFileWithError(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -426,6 +426,10 @@ role: user
|
|||||||
message: Fix these 1 TypeScript compile-time error:
|
message: Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
||||||
|
```
|
||||||
|
finalMainTsxFileWithError(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
|
|
||||||
@@ -449,5 +453,9 @@ role: user
|
|||||||
message: Fix these 1 TypeScript compile-time error:
|
message: Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
1. src/main.tsx:1:1 - Cannot find name 'finalMainTsxFileWithError'. (TS2304)
|
||||||
|
```
|
||||||
|
finalMainTsxFileWithError(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -436,6 +436,15 @@ role: user
|
|||||||
message: Fix these 2 TypeScript compile-time errors:
|
message: Fix these 2 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.ts:4:3 - Property 'nonExistentMethod' does not exist on type 'Object'. (TS2339)
|
2. src/bad-file.ts:4:3 - Property 'nonExistentMethod' does not exist on type 'Object'. (TS2339)
|
||||||
|
```
|
||||||
|
const x = new Object();
|
||||||
|
x.nonExistentMethod(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -438,7 +438,16 @@ role: user
|
|||||||
message: Fix these 2 TypeScript compile-time errors:
|
message: Fix these 2 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.ts:4:3 - Property 'nonExistentMethod' does not exist on type 'Object'. (TS2339)
|
2. src/bad-file.ts:4:3 - Property 'nonExistentMethod' does not exist on type 'Object'. (TS2339)
|
||||||
|
```
|
||||||
|
const x = new Object();
|
||||||
|
x.nonExistentMethod(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
|
|
||||||
@@ -462,5 +471,10 @@ role: user
|
|||||||
message: Fix these 1 TypeScript compile-time error:
|
message: Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/bad-file.ts:6:3 - Property 'nonExistentMethod2' does not exist on type 'Object'. (TS2339)
|
1. src/bad-file.ts:6:3 - Property 'nonExistentMethod2' does not exist on type 'Object'. (TS2339)
|
||||||
|
```
|
||||||
|
const x = new Object();
|
||||||
|
x.nonExistentMethod2(); // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -438,9 +438,37 @@ role: user
|
|||||||
message: Fix these 5 TypeScript compile-time errors:
|
message: Fix these 5 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class';
|
||||||
|
import NonExistentClass2 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
import NonExistentClass3 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
import NonExistentClass4 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass5 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
import NonExistentClass5 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -442,10 +442,38 @@ role: user
|
|||||||
message: Fix these 5 TypeScript compile-time errors:
|
message: Fix these 5 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class';
|
||||||
|
import NonExistentClass2 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
import NonExistentClass3 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
import NonExistentClass4 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass5 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
import NonExistentClass5 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
|
|
||||||
@@ -464,9 +492,37 @@ role: user
|
|||||||
message: Fix these 5 TypeScript compile-time errors:
|
message: Fix these 5 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
1. src/bad-file.ts:1:30 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
2. src/bad-file.ts:2:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass from 'non-existent-class';
|
||||||
|
import NonExistentClass2 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
3. src/bad-file.ts:3:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass2 from 'non-existent-class';
|
||||||
|
import NonExistentClass3 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
4. src/bad-file.ts:4:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass3 from 'non-existent-class';
|
||||||
|
import NonExistentClass4 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
import NonExistentClass5 from 'non-existent-class';
|
||||||
|
```
|
||||||
|
|
||||||
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
5. src/bad-file.ts:5:31 - Cannot find module 'non-existent-class' or its corresponding type declarations. (TS2307)
|
||||||
|
```
|
||||||
|
import NonExistentClass4 from 'non-existent-class';
|
||||||
|
import NonExistentClass5 from 'non-existent-class'; // <-- TypeScript compiler error here
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way.
|
Please fix all errors in a concise way.
|
||||||
@@ -17,6 +17,7 @@ export interface Problem {
|
|||||||
column: number;
|
column: number;
|
||||||
message: string;
|
message: string;
|
||||||
code: number;
|
code: number;
|
||||||
|
snippet: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProblemReport {
|
export interface ProblemReport {
|
||||||
|
|||||||
@@ -4,7 +4,15 @@ exports[`problem_prompt > createConciseProblemFixPrompt > should format a concis
|
|||||||
"Fix these 2 TypeScript compile-time errors:
|
"Fix these 2 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/main.ts:5:12 - Cannot find module 'react-dom/client' or its corresponding type declarations. (TS2307)
|
1. src/main.ts:5:12 - Cannot find module 'react-dom/client' or its corresponding type declarations. (TS2307)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
2. src/components/Modal.tsx:35:20 - Property 'isOpen' does not exist on type 'IntrinsicAttributes & ModalProps'. (TS2339)
|
2. src/components/Modal.tsx:35:20 - Property 'isOpen' does not exist on type 'IntrinsicAttributes & ModalProps'. (TS2339)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
@@ -13,6 +21,10 @@ exports[`problem_prompt > createConciseProblemFixPrompt > should format a concis
|
|||||||
"Fix these 1 TypeScript compile-time error:
|
"Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/App.tsx:10:5 - Cannot find name 'consol'. Did you mean 'console'? (TS2552)
|
1. src/App.tsx:10:5 - Cannot find name 'consol'. Did you mean 'console'? (TS2552)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
@@ -23,6 +35,10 @@ exports[`problem_prompt > createProblemFixPrompt > should format a single error
|
|||||||
"Fix these 1 TypeScript compile-time error:
|
"Fix these 1 TypeScript compile-time error:
|
||||||
|
|
||||||
1. src/components/Button.tsx:15:23 - Property 'onClick' does not exist on type 'ButtonProps'. (TS2339)
|
1. src/components/Button.tsx:15:23 - Property 'onClick' does not exist on type 'ButtonProps'. (TS2339)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
@@ -31,9 +47,25 @@ exports[`problem_prompt > createProblemFixPrompt > should format multiple errors
|
|||||||
"Fix these 4 TypeScript compile-time errors:
|
"Fix these 4 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/components/Button.tsx:15:23 - Property 'onClick' does not exist on type 'ButtonProps'. (TS2339)
|
1. src/components/Button.tsx:15:23 - Property 'onClick' does not exist on type 'ButtonProps'. (TS2339)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
2. src/components/Button.tsx:8:12 - Type 'string | undefined' is not assignable to type 'string'. (TS2322)
|
2. src/components/Button.tsx:8:12 - Type 'string | undefined' is not assignable to type 'string'. (TS2322)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
3. src/hooks/useApi.ts:42:5 - Argument of type 'unknown' is not assignable to parameter of type 'string'. (TS2345)
|
3. src/hooks/useApi.ts:42:5 - Argument of type 'unknown' is not assignable to parameter of type 'string'. (TS2345)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
4. src/utils/helpers.ts:45:8 - Function lacks ending return statement and return type does not include 'undefined'. (TS2366)
|
4. src/utils/helpers.ts:45:8 - Function lacks ending return statement and return type does not include 'undefined'. (TS2366)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
@@ -42,9 +74,25 @@ exports[`problem_prompt > createProblemFixPrompt > should handle realistic React
|
|||||||
"Fix these 4 TypeScript compile-time errors:
|
"Fix these 4 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/components/UserProfile.tsx:12:35 - Type '{ children: string; }' is missing the following properties from type 'UserProfileProps': user, onEdit (TS2739)
|
1. src/components/UserProfile.tsx:12:35 - Type '{ children: string; }' is missing the following properties from type 'UserProfileProps': user, onEdit (TS2739)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
2. src/components/UserProfile.tsx:25:15 - Object is possibly 'null'. (TS2531)
|
2. src/components/UserProfile.tsx:25:15 - Object is possibly 'null'. (TS2531)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
3. src/hooks/useLocalStorage.ts:18:12 - Type 'string | null' is not assignable to type 'T'. (TS2322)
|
3. src/hooks/useLocalStorage.ts:18:12 - Type 'string | null' is not assignable to type 'T'. (TS2322)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
4. src/types/api.ts:45:3 - Duplicate identifier 'UserRole'. (TS2300)
|
4. src/types/api.ts:45:3 - Duplicate identifier 'UserRole'. (TS2300)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
@@ -55,9 +103,25 @@ exports[`problem_prompt > realistic TypeScript error scenarios > should handle c
|
|||||||
"Fix these 4 TypeScript compile-time errors:
|
"Fix these 4 TypeScript compile-time errors:
|
||||||
|
|
||||||
1. src/components/ProductCard.tsx:22:18 - Property 'price' is missing in type '{ name: string; description: string; }' but required in type 'Product'. (TS2741)
|
1. src/components/ProductCard.tsx:22:18 - Property 'price' is missing in type '{ name: string; description: string; }' but required in type 'Product'. (TS2741)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
2. src/components/SearchInput.tsx:15:45 - Type '(value: string) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement>'. (TS2322)
|
2. src/components/SearchInput.tsx:15:45 - Type '(value: string) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement>'. (TS2322)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
3. src/api/userService.ts:8:1 - Function lacks ending return statement and return type does not include 'undefined'. (TS2366)
|
3. src/api/userService.ts:8:1 - Function lacks ending return statement and return type does not include 'undefined'. (TS2366)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
4. src/utils/dataProcessor.ts:34:25 - Object is possibly 'undefined'. (TS2532)
|
4. src/utils/dataProcessor.ts:34:25 - Object is possibly 'undefined'. (TS2532)
|
||||||
|
\`\`\`
|
||||||
|
SNIPPET
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
|
||||||
Please fix all errors in a concise way."
|
Please fix all errors in a concise way."
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { describe, it, expect } from "vitest";
|
|||||||
import { createProblemFixPrompt } from "../shared/problem_prompt";
|
import { createProblemFixPrompt } from "../shared/problem_prompt";
|
||||||
import type { ProblemReport } from "../ipc/ipc_types";
|
import type { ProblemReport } from "../ipc/ipc_types";
|
||||||
|
|
||||||
|
const snippet = `SNIPPET`;
|
||||||
|
|
||||||
describe("problem_prompt", () => {
|
describe("problem_prompt", () => {
|
||||||
describe("createProblemFixPrompt", () => {
|
describe("createProblemFixPrompt", () => {
|
||||||
it("should return a message when no problems exist", () => {
|
it("should return a message when no problems exist", () => {
|
||||||
@@ -22,6 +24,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 23,
|
column: 23,
|
||||||
message: "Property 'onClick' does not exist on type 'ButtonProps'.",
|
message: "Property 'onClick' does not exist on type 'ButtonProps'.",
|
||||||
code: 2339,
|
code: 2339,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -39,6 +42,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 23,
|
column: 23,
|
||||||
message: "Property 'onClick' does not exist on type 'ButtonProps'.",
|
message: "Property 'onClick' does not exist on type 'ButtonProps'.",
|
||||||
code: 2339,
|
code: 2339,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/components/Button.tsx",
|
file: "src/components/Button.tsx",
|
||||||
@@ -47,6 +51,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Type 'string | undefined' is not assignable to type 'string'.",
|
"Type 'string | undefined' is not assignable to type 'string'.",
|
||||||
code: 2322,
|
code: 2322,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/hooks/useApi.ts",
|
file: "src/hooks/useApi.ts",
|
||||||
@@ -55,6 +60,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Argument of type 'unknown' is not assignable to parameter of type 'string'.",
|
"Argument of type 'unknown' is not assignable to parameter of type 'string'.",
|
||||||
code: 2345,
|
code: 2345,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/utils/helpers.ts",
|
file: "src/utils/helpers.ts",
|
||||||
@@ -63,6 +69,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Function lacks ending return statement and return type does not include 'undefined'.",
|
"Function lacks ending return statement and return type does not include 'undefined'.",
|
||||||
code: 2366,
|
code: 2366,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -81,6 +88,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Type '{ children: string; }' is missing the following properties from type 'UserProfileProps': user, onEdit",
|
"Type '{ children: string; }' is missing the following properties from type 'UserProfileProps': user, onEdit",
|
||||||
code: 2739,
|
code: 2739,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/components/UserProfile.tsx",
|
file: "src/components/UserProfile.tsx",
|
||||||
@@ -88,6 +96,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 15,
|
column: 15,
|
||||||
message: "Object is possibly 'null'.",
|
message: "Object is possibly 'null'.",
|
||||||
code: 2531,
|
code: 2531,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/hooks/useLocalStorage.ts",
|
file: "src/hooks/useLocalStorage.ts",
|
||||||
@@ -95,6 +104,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 12,
|
column: 12,
|
||||||
message: "Type 'string | null' is not assignable to type 'T'.",
|
message: "Type 'string | null' is not assignable to type 'T'.",
|
||||||
code: 2322,
|
code: 2322,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/types/api.ts",
|
file: "src/types/api.ts",
|
||||||
@@ -102,6 +112,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 3,
|
column: 3,
|
||||||
message: "Duplicate identifier 'UserRole'.",
|
message: "Duplicate identifier 'UserRole'.",
|
||||||
code: 2300,
|
code: 2300,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -130,6 +141,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 5,
|
column: 5,
|
||||||
message: "Cannot find name 'consol'. Did you mean 'console'?",
|
message: "Cannot find name 'consol'. Did you mean 'console'?",
|
||||||
code: 2552,
|
code: 2552,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -148,6 +160,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Cannot find module 'react-dom/client' or its corresponding type declarations.",
|
"Cannot find module 'react-dom/client' or its corresponding type declarations.",
|
||||||
code: 2307,
|
code: 2307,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "src/components/Modal.tsx",
|
file: "src/components/Modal.tsx",
|
||||||
@@ -156,6 +169,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Property 'isOpen' does not exist on type 'IntrinsicAttributes & ModalProps'.",
|
"Property 'isOpen' does not exist on type 'IntrinsicAttributes & ModalProps'.",
|
||||||
code: 2339,
|
code: 2339,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -177,6 +191,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Property 'price' is missing in type '{ name: string; description: string; }' but required in type 'Product'.",
|
"Property 'price' is missing in type '{ name: string; description: string; }' but required in type 'Product'.",
|
||||||
code: 2741,
|
code: 2741,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
// Incorrect event handler type
|
// Incorrect event handler type
|
||||||
{
|
{
|
||||||
@@ -186,6 +201,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Type '(value: string) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement>'.",
|
"Type '(value: string) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement>'.",
|
||||||
code: 2322,
|
code: 2322,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
// Async/await without Promise return type
|
// Async/await without Promise return type
|
||||||
{
|
{
|
||||||
@@ -195,6 +211,7 @@ describe("problem_prompt", () => {
|
|||||||
message:
|
message:
|
||||||
"Function lacks ending return statement and return type does not include 'undefined'.",
|
"Function lacks ending return statement and return type does not include 'undefined'.",
|
||||||
code: 2366,
|
code: 2366,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
// Strict null check
|
// Strict null check
|
||||||
{
|
{
|
||||||
@@ -203,6 +220,7 @@ describe("problem_prompt", () => {
|
|||||||
column: 25,
|
column: 25,
|
||||||
message: "Object is possibly 'undefined'.",
|
message: "Object is possibly 'undefined'.",
|
||||||
code: 2532,
|
code: 2532,
|
||||||
|
snippet,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import type { Problem } from "@/ipc/ipc_types";
|
import type { Problem } from "@/ipc/ipc_types";
|
||||||
|
|
||||||
|
type ProblemWithoutSnippet = Omit<Problem, "snippet">;
|
||||||
|
|
||||||
interface DyadProblemSummaryProps {
|
interface DyadProblemSummaryProps {
|
||||||
summary?: string;
|
summary?: string;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProblemItemProps {
|
interface ProblemItemProps {
|
||||||
problem: Problem;
|
problem: ProblemWithoutSnippet;
|
||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,13 +56,13 @@ export const DyadProblemSummary: React.FC<DyadProblemSummaryProps> = ({
|
|||||||
const [isContentVisible, setIsContentVisible] = useState(false);
|
const [isContentVisible, setIsContentVisible] = useState(false);
|
||||||
|
|
||||||
// Parse problems from children content if available
|
// Parse problems from children content if available
|
||||||
const problems: Problem[] = React.useMemo(() => {
|
const problems: ProblemWithoutSnippet[] = React.useMemo(() => {
|
||||||
if (!children || typeof children !== "string") return [];
|
if (!children || typeof children !== "string") return [];
|
||||||
|
|
||||||
// Parse structured format with <problem> tags
|
// Parse structured format with <problem> tags
|
||||||
const problemTagRegex =
|
const problemTagRegex =
|
||||||
/<problem\s+file="([^"]+)"\s+line="(\d+)"\s+column="(\d+)"\s+code="(\d+)">([^<]+)<\/problem>/g;
|
/<problem\s+file="([^"]+)"\s+line="(\d+)"\s+column="(\d+)"\s+code="(\d+)">([^<]+)<\/problem>/g;
|
||||||
const problems: Problem[] = [];
|
const problems: ProblemWithoutSnippet[] = [];
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = problemTagRegex.exec(children)) !== null) {
|
while ((match = problemTagRegex.exec(children)) !== null) {
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ const ProblemsSummary = ({ problemReport, appId }: ProblemsSummaryProps) => {
|
|||||||
const { problems } = problemReport;
|
const { problems } = problemReport;
|
||||||
const totalErrors = problems.length;
|
const totalErrors = problems.length;
|
||||||
const [selectedChatId] = useAtom(selectedChatIdAtom);
|
const [selectedChatId] = useAtom(selectedChatIdAtom);
|
||||||
|
|
||||||
const handleFixAll = () => {
|
const handleFixAll = () => {
|
||||||
if (!selectedChatId) {
|
if (!selectedChatId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export function createProblemFixPrompt(problemReport: ProblemReport): string {
|
|||||||
|
|
||||||
problems.forEach((problem, index) => {
|
problems.forEach((problem, index) => {
|
||||||
prompt += `${index + 1}. ${problem.file}:${problem.line}:${problem.column} - ${problem.message} (TS${problem.code})\n`;
|
prompt += `${index + 1}. ${problem.file}:${problem.line}:${problem.column} - ${problem.message} (TS${problem.code})\n`;
|
||||||
|
if (problem.snippet) {
|
||||||
|
prompt += `\`\`\`\n${problem.snippet}\n\`\`\`\n`;
|
||||||
|
}
|
||||||
|
prompt += "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
prompt += "\nPlease fix all errors in a concise way.";
|
prompt += "\nPlease fix all errors in a concise way.";
|
||||||
|
|||||||
@@ -188,12 +188,25 @@ async function runSingleProject(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract the problematic line with context
|
||||||
|
const sourceLines = diagnostic.file.getFullText().split(/\r?\n/);
|
||||||
|
const lineBefore = line > 0 ? sourceLines[line - 1] : "";
|
||||||
|
const problematicLine = sourceLines[line] || "";
|
||||||
|
const lineAfter =
|
||||||
|
line < sourceLines.length - 1 ? sourceLines[line + 1] : "";
|
||||||
|
|
||||||
|
let snippet = "";
|
||||||
|
if (lineBefore) snippet += lineBefore + "\n";
|
||||||
|
snippet += problematicLine + " // <-- TypeScript compiler error here\n";
|
||||||
|
if (lineAfter) snippet += lineAfter;
|
||||||
|
|
||||||
problems.push({
|
problems.push({
|
||||||
file: normalizePath(path.relative(appPath, diagnostic.file.fileName)),
|
file: normalizePath(path.relative(appPath, diagnostic.file.fileName)),
|
||||||
line: line + 1, // Convert to 1-based
|
line: line + 1, // Convert to 1-based
|
||||||
column: character + 1, // Convert to 1-based
|
column: character + 1, // Convert to 1-based
|
||||||
message,
|
message,
|
||||||
code: diagnostic.code,
|
code: diagnostic.code,
|
||||||
|
snippet: snippet.trim(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user