fix errors

This commit is contained in:
Abi Raja 2023-12-07 09:36:37 -05:00
parent 874afc1e66
commit dd0f3b7648
3 changed files with 22 additions and 17 deletions

View File

@ -128,7 +128,7 @@ function App() {
function doGenerateCode( function doGenerateCode(
params: CodeGenerationParams, params: CodeGenerationParams,
parentVersion?: number parentVersion: number | null
) { ) {
setExecutionConsole([]); setExecutionConsole([]);
setAppState(AppState.CODING); setAppState(AppState.CODING);
@ -166,7 +166,6 @@ function App() {
...prev, ...prev,
{ {
type: "ai_edit", type: "ai_edit",
// TODO: It should never be null
parent: parentVersion, parent: parentVersion,
code, code,
inputs: { inputs: {
@ -193,10 +192,13 @@ function App() {
setReferenceImages(referenceImages); setReferenceImages(referenceImages);
if (referenceImages.length > 0) { if (referenceImages.length > 0) {
doGenerateCode({ doGenerateCode(
{
generationType: "create", generationType: "create",
image: referenceImages[0], image: referenceImages[0],
}); },
currentVersion
);
} }
} }

View File

@ -54,9 +54,11 @@ export default function HistoryDisplay({
> >
<div className="flex gap-x-1"> <div className="flex gap-x-1">
<h2 className="text-sm">{displayHistoryItemType(item.type)}</h2> <h2 className="text-sm">{displayHistoryItemType(item.type)}</h2>
{item.parent && item.parent !== index - 1 && ( {item.parent && item.parent !== index - 1 ? (
<h2 className="text-sm">(parent: v{item.parent + 1})</h2> <h2 className="text-sm">
)} (parent: v{(item.parent || 0) + 1})
</h2>
) : null}
</div> </div>
<h2 className="text-sm"> <h2 className="text-sm">
{item.type === "ai_edit" {item.type === "ai_edit"

View File

@ -1,19 +1,20 @@
export type HistoryItemType = "ai_create" | "ai_edit"; export type HistoryItemType = "ai_create" | "ai_edit";
export type HistoryItem = type CommonHistoryItem = {
| {
type: "ai_create";
parent: null | number; parent: null | number;
code: string; code: string;
inputs: AiCreateInputs;
}
| {
type: "ai_edit";
parent: null | number;
code: string;
inputs: AiEditInputs;
}; };
export type HistoryItem =
| ({
type: "ai_create";
inputs: AiCreateInputs;
} & CommonHistoryItem)
| ({
type: "ai_edit";
inputs: AiEditInputs;
} & CommonHistoryItem);
export type AiCreateInputs = { export type AiCreateInputs = {
image_url: string; image_url: string;
}; };