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

View File

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

View File

@ -1,19 +1,20 @@
export type HistoryItemType = "ai_create" | "ai_edit";
export type HistoryItem =
| {
type: "ai_create";
type CommonHistoryItem = {
parent: null | number;
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 = {
image_url: string;
};