diff --git a/client/src/components/infoview/main.tsx b/client/src/components/infoview/main.tsx index 1004ec1..0680fa9 100644 --- a/client/src/components/infoview/main.tsx +++ b/client/src/components/infoview/main.tsx @@ -34,6 +34,7 @@ import { Button } from '../button'; import { CircularProgress } from '@mui/material'; import { GameHint } from './rpc_api'; import { store } from '../../state/store'; +import { Hints } from '../hints'; /** Wrapper for the two editors. It is important that the `div` with `codeViewRef` is * always present, or the monaco editor cannot start. @@ -288,7 +289,7 @@ export function CommandLineInterface(props: { world: string, level: number, data const gameId = React.useContext(GameIdContext) const { proof } = React.useContext(ProofContext) const { selectedStep, setSelectedStep } = React.useContext(SelectionContext) - const { setDeletedChat, showHelp } = React.useContext(DeletedChatContext) + const { setDeletedChat, showHelp, setShowHelp } = React.useContext(DeletedChatContext) const {mobile} = React.useContext(MobileContext) @@ -377,6 +378,37 @@ export function CommandLineInterface(props: { world: string, level: number, data } + // TODO: This about hidden hints is all copied from `level.tsx`. Can we move that into `hints.tsx`? + + // If the last step has errors, we want to treat it as if it is part of the second-to-last step + let k = proof.length - 1 + let withErr = hasInteractiveErrors(proof[k]?.errors) ? 1 : 0 + + const activateHiddenHints = (ev) => { + // If the last step (`k`) has errors, we want the hidden hints from the + // second-to-last step to be affected + if (!(proof.length)) {return} + + // state must not be mutated, therefore we need to clone the set + let tmp = new Set(showHelp) + if (tmp.has(k - withErr)) { + tmp.delete(k - withErr) + } else { + tmp.add(k - withErr) + } + setShowHelp(tmp) + console.debug(`help: ${Array.from(tmp.values())}`) + } + + function hasHiddenHints(i : number): boolean { + let step = proof[i] + + // For example if the proof isn't loaded yet + if(!step) {return false} + + return step.hints.some((hint) => hint.hidden) + } + return