- {/* We need the editor to be hidden because the command line edits its content */}
+ {/* We need the editor to always there and hidden because
+ the command line edits its content */}
- {commandLineMode && }
- {/*
{level?.data?.descrFormat}
*/}
- {/* */}
+ worldId={worldId} levelId={levelId} editorConnection={editorConnection}/>
+ { // TODO: Is there any possibility that the editor connection takes a while
+ // and we should show a circular progress here?
+ commandLineMode && editorConnection &&
+
+ }
- {/*
- {commandLineMode && }
-
*/}
- {/* {editorConnection && } */}
diff --git a/client/src/components/infoview/main.tsx b/client/src/components/infoview/main.tsx
index e90eff6..5ffa88a 100644
--- a/client/src/components/infoview/main.tsx
+++ b/client/src/components/infoview/main.tsx
@@ -115,3 +115,87 @@ export function EditorInterface({data, codeviewRef, hidden, worldId, levelId, ed
}
+
+export function ReducedInterface(props: {world: string, level: number}) {
+
+ const ec = React.useContext(EditorContext);
+ const gameId = React.useContext(GameIdContext)
+
+ const dispatch = useAppDispatch()
+
+ // Mark level as completed when server gives notification
+ useServerNotificationEffect(
+ '$/game/completed',
+ (params: any) => {
+
+ if (ec.events.changedCursorLocation.current &&
+ ec.events.changedCursorLocation.current.uri === params.uri) {
+ dispatch(levelCompleted({game: gameId, world: props.world, level: props.level}))
+ }
+ },
+ []
+ );
+
+ const completed = useAppSelector(selectCompleted(gameId, props.world, props.level))
+
+ /* Set up updates to the global infoview state on editor events. */
+ const config = useEventResult(ec.events.changedInfoviewConfig) ?? defaultInfoviewConfig;
+
+ const [allProgress, _1] = useServerNotificationState(
+ '$/lean/fileProgress',
+ new Map(),
+ async (params: LeanFileProgressParams) => (allProgress) => {
+ const newProgress = new Map(allProgress);
+ return newProgress.set(params.textDocument.uri, params.processing);
+ },
+ []
+ );
+
+ const curUri = useEventResult(ec.events.changedCursorLocation, loc => loc?.uri);
+
+ useClientNotificationEffect(
+ 'textDocument/didClose',
+ (params: DidCloseTextDocumentParams) => {
+ if (ec.events.changedCursorLocation.current &&
+ ec.events.changedCursorLocation.current.uri === params.textDocument.uri) {
+ ec.events.changedCursorLocation.fire(undefined)
+ }
+ },
+ []
+ );
+
+ const serverVersion =
+ useEventResult(ec.events.serverRestarted, result => new ServerVersion(result.serverInfo?.version ?? ''))
+ const serverStoppedResult = useEventResult(ec.events.serverStopped);
+ // NB: the cursor may temporarily become `undefined` when a file is closed. In this case
+ // it's important not to reconstruct the `WithBlah` wrappers below since they contain state
+ // that we want to persist.
+ let ret
+ if (!serverVersion) {
+ ret =