}
@@ -266,11 +266,11 @@ function Command({ proof, i, deleteProof }: { proof: ProofState, i: number, dele
// If the last step has errors, we display the command in a different style
// indicating that it will be removed on the next try.
return
@@ -414,7 +414,7 @@ export function TypewriterInterface({props}) {
function deleteProof(line: number) {
return (ev) => {
let deletedChat: Array = []
- proof.steps.slice(line).map((step, i) => {
+ proof?.steps.slice(line).map((step, i) => {
let filteredHints = filterHints(step.goals[0]?.hints, proof?.steps[i-1]?.goals[0]?.hints)
// Only add these hidden hints to the deletion stack which were visible
@@ -431,7 +431,7 @@ export function TypewriterInterface({props}) {
forceMoveMarkers: false
}])
setSelectedStep(undefined)
- setTypewriterInput(proof.steps[line].command)
+ setTypewriterInput(proof?.steps[line].command)
// Reload proof on deleting
loadGoals(rpcSess, uri, setProof)
ev.stopPropagation()
@@ -453,7 +453,7 @@ export function TypewriterInterface({props}) {
// Scroll to the end of the proof if it is updated.
React.useEffect(() => {
- if (proof.steps.length > 1) {
+ if (proof?.steps.length > 1) {
proofPanelRef.current?.lastElementChild?.scrollIntoView() //scrollTo(0,0)
} else {
proofPanelRef.current?.scrollTo(0,0)
@@ -475,7 +475,7 @@ export function TypewriterInterface({props}) {
}, [selectedStep])
// TODO: superfluous, can be replaced with `withErr` from above
- let lastStepErrors = proof.steps.length ? hasInteractiveErrors(getInteractiveDiagsAt(proof, proof.steps.length)) : false
+ let lastStepErrors = proof?.steps.length ? hasInteractiveErrors(getInteractiveDiagsAt(proof, proof?.steps.length)) : false
useServerNotificationEffect("$/game/loading", (params : any) => {
@@ -495,12 +495,12 @@ export function TypewriterInterface({props}) {
- {proof.steps.length ?
+ {proof?.steps.length ?
<>
- {proof.steps.map((step, i) => {
+ {proof?.steps.map((step, i) => {
let filteredHints = filterHints(step.goals[0]?.hints, proof?.steps[i-1]?.goals[0]?.hints)
- // if (i == proof.steps.length - 1 && hasInteractiveErrors(step.diags)) {
+ // if (i == proof?.steps.length - 1 && hasInteractiveErrors(step.diags)) {
// // if the last command contains an error, we only display the errors but not the
// // entered command as it is still present in the command line.
// // TODO: Should not use index as key.
@@ -521,18 +521,18 @@ export function TypewriterInterface({props}) {
hints={filteredHints} showHidden={showHelp.has(i)} step={i}
selected={selectedStep} toggleSelection={toggleSelectStep(i)}/>
}
- {/* setDisableInput(n > 0) : (n) => {}}/> */}
+ {/* setDisableInput(n > 0) : (n) => {}}/> */}
{!(isLastStepWithErrors(proof, i)) &&
- setDisableInput(n > 0) : (n) => {}}/>
+ setDisableInput(n > 0) : (n) => {}}/>
}
- {mobile && i == proof.steps.length - 1 &&
+ {mobile && i == proof?.steps.length - 1 &&
}
{/* Show a message that there are no goals left */}
{/* {!step.goals.length && (
- {proof.completed ?
+ {proof?.completed ?
Level completed! 🎉
:
no goals left
@@ -545,12 +545,12 @@ export function TypewriterInterface({props}) {
}
//}
)}
- {proof.diagnostics.length > 0 &&
+ {proof?.diagnostics.length > 0 &&
}
diff --git a/client/src/components/infoview/typewriter.tsx b/client/src/components/infoview/typewriter.tsx
index e457af0..2b50a69 100644
--- a/client/src/components/infoview/typewriter.tsx
+++ b/client/src/components/infoview/typewriter.tsx
@@ -230,7 +230,7 @@ export function Typewriter({disabled}: {disabled?: boolean}) {
/** If the last step has an error, add the command to the typewriter. */
useEffect(() => {
if (lastStepHasErrors(proof)) {
- setTypewriterInput(proof.steps[proof.steps.length - 1].command)
+ setTypewriterInput(proof?.steps[proof?.steps.length - 1].command)
}
}, [proof])
@@ -344,7 +344,7 @@ export function Typewriter({disabled}: {disabled?: boolean}) {
}
// do not display if the proof is completed (with potential warnings still present)
- return