throw exceptions so Sentry can capture them
This commit is contained in:
parent
939d4eebf8
commit
bf3e4eecb2
@ -126,19 +126,20 @@ function App() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const regenerate = () => {
|
const regenerate = () => {
|
||||||
// TODO: post to Sentry
|
|
||||||
if (head === null) {
|
if (head === null) {
|
||||||
toast.error(
|
toast.error(
|
||||||
"No current version set. Please open a Github issue as this shouldn't happen."
|
"No current version set. Please contact support via chat or Github."
|
||||||
);
|
);
|
||||||
return;
|
throw new Error("Regenerate called with no head");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the previous command
|
// Retrieve the previous command
|
||||||
const currentCommit = commits[head];
|
const currentCommit = commits[head];
|
||||||
if (currentCommit.type !== "ai_create") {
|
if (currentCommit.type !== "ai_create") {
|
||||||
toast.error("Only the first version can be regenerated.");
|
toast.error("Only the first version can be regenerated.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-run the create
|
// Re-run the create
|
||||||
doCreate(referenceImages, inputMode);
|
doCreate(referenceImages, inputMode);
|
||||||
};
|
};
|
||||||
@ -147,7 +148,7 @@ function App() {
|
|||||||
const cancelCodeGeneration = () => {
|
const cancelCodeGeneration = () => {
|
||||||
wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE);
|
wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE);
|
||||||
// make sure stop can correct the state even if the websocket is already closed
|
// make sure stop can correct the state even if the websocket is already closed
|
||||||
// TODO: Look into this
|
// TODO*: Look into this
|
||||||
// cancelCodeGenerationAndReset();
|
// cancelCodeGenerationAndReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ function App() {
|
|||||||
if (parentCommitHash) {
|
if (parentCommitHash) {
|
||||||
setHead(parentCommitHash);
|
setHead(parentCommitHash);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Hit Sentry
|
throw new Error("Parent commit not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
setAppState(AppState.CODE_READY);
|
setAppState(AppState.CODE_READY);
|
||||||
@ -205,6 +206,7 @@ function App() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create a new commit and set it as the head
|
||||||
const commit = createCommit(commitInputObject);
|
const commit = createCommit(commitInputObject);
|
||||||
addCommit(commit);
|
addCommit(commit);
|
||||||
setHead(commit.hash);
|
setHead(commit.hash);
|
||||||
@ -262,22 +264,21 @@ function App() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (currentVersion === null) {
|
if (head === null) {
|
||||||
// toast.error(
|
toast.error(
|
||||||
// "No current version set. Contact support or open a Github issue."
|
"No current version set. Contact support or open a Github issue."
|
||||||
// );
|
);
|
||||||
// return;
|
throw new Error("Update called with no head");
|
||||||
// }
|
}
|
||||||
|
|
||||||
let historyTree;
|
let historyTree;
|
||||||
try {
|
try {
|
||||||
// TODO: Fix head being null
|
historyTree = extractHistory(head, commits);
|
||||||
historyTree = extractHistory(head || "", commits);
|
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(
|
toast.error(
|
||||||
"Version history is invalid. This shouldn't happen. Please contact support or open a Github issue."
|
"Version history is invalid. This shouldn't happen. Please contact support or open a Github issue."
|
||||||
);
|
);
|
||||||
return;
|
throw new Error("Invalid version history");
|
||||||
}
|
}
|
||||||
|
|
||||||
let modifiedUpdateInstruction = updateInstruction;
|
let modifiedUpdateInstruction = updateInstruction;
|
||||||
@ -291,28 +292,18 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updatedHistory = [...historyTree, modifiedUpdateInstruction];
|
const updatedHistory = [...historyTree, modifiedUpdateInstruction];
|
||||||
|
const resultImage = shouldIncludeResultImage
|
||||||
|
? await takeScreenshot()
|
||||||
|
: undefined;
|
||||||
|
|
||||||
console.log(updatedHistory);
|
doGenerateCode({
|
||||||
|
generationType: "update",
|
||||||
if (shouldIncludeResultImage) {
|
inputMode,
|
||||||
const resultImage = await takeScreenshot();
|
image: referenceImages[0],
|
||||||
doGenerateCode({
|
resultImage,
|
||||||
generationType: "update",
|
history: updatedHistory,
|
||||||
inputMode,
|
isImportedFromCode,
|
||||||
image: referenceImages[0],
|
});
|
||||||
resultImage: resultImage,
|
|
||||||
history: updatedHistory,
|
|
||||||
isImportedFromCode,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
doGenerateCode({
|
|
||||||
generationType: "update",
|
|
||||||
inputMode,
|
|
||||||
image: referenceImages[0],
|
|
||||||
history: updatedHistory,
|
|
||||||
isImportedFromCode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdateInstruction("");
|
setUpdateInstruction("");
|
||||||
}
|
}
|
||||||
@ -338,7 +329,7 @@ function App() {
|
|||||||
// Set up this project
|
// Set up this project
|
||||||
setStack(stack);
|
setStack(stack);
|
||||||
|
|
||||||
// Set up the import commit
|
// Create a new commit and set it as the head
|
||||||
const commit = createCommit({
|
const commit = createCommit({
|
||||||
type: "code_create",
|
type: "code_create",
|
||||||
parentHash: null,
|
parentHash: null,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user