fix code not executing tauri project load (#2165)

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-04-18 12:40:05 -07:00
committed by GitHub
parent ac140c054f
commit 38d9b5d4b4
3 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import { APP_NAME } from 'lib/constants'
import { useCommandsContext } from 'hooks/useCommandsContext' import { useCommandsContext } from 'hooks/useCommandsContext'
import { CustomIcon } from './CustomIcon' import { CustomIcon } from './CustomIcon'
import { useLspContext } from './LspProvider' import { useLspContext } from './LspProvider'
import { engineCommandManager } from 'lib/singletons'
const ProjectSidebarMenu = ({ const ProjectSidebarMenu = ({
project, project,
@ -28,6 +29,8 @@ const ProjectSidebarMenu = ({
<Link <Link
onClick={() => { onClick={() => {
onProjectClose(file || null, project?.path || null, false) onProjectClose(file || null, project?.path || null, false)
// Clear the scene and end the session.
engineCommandManager.endSession()
}} }}
to={paths.HOME} to={paths.HOME}
className="relative h-full grid place-content-center group p-1.5 before:block before:content-[''] before:absolute before:inset-0 before:bottom-2.5 before:z-[-1] before:bg-primary hover:before:brightness-110 before:rounded-b-sm" className="relative h-full grid place-content-center group p-1.5 before:block before:content-[''] before:absolute before:inset-0 before:bottom-2.5 before:z-[-1] before:bg-primary hover:before:brightness-110 before:rounded-b-sm"
@ -39,6 +42,8 @@ const ProjectSidebarMenu = ({
<Link <Link
onClick={() => { onClick={() => {
onProjectClose(file || null, project?.path || null, false) onProjectClose(file || null, project?.path || null, false)
// Clear the scene and end the session.
engineCommandManager.endSession()
}} }}
to={paths.HOME} to={paths.HOME}
className="!no-underline" className="!no-underline"
@ -177,6 +182,8 @@ function ProjectMenuPopover({
Element="button" Element="button"
onClick={() => { onClick={() => {
onProjectClose(file || null, project?.path || null, true) onProjectClose(file || null, project?.path || null, true)
// Clear the scene and end the session.
engineCommandManager.endSession()
}} }}
icon={{ icon={{
icon: 'arrowLeft', icon: 'arrowLeft',

View File

@ -259,7 +259,11 @@ export class KclManager {
executeCode(force?: boolean) { executeCode(force?: boolean) {
// If we want to force it we don't want to defer it. // If we want to force it we don't want to defer it.
if (!force) return this._defferer(codeManager.code) if (!force) return this._defferer(codeManager.code)
return this.executeAst()
const ast = this.safeParse(codeManager.code)
if (!ast) return
this.ast = { ...ast }
return this.executeAst(ast)
} }
format() { format() {
const originalCode = codeManager.code const originalCode = codeManager.code

View File

@ -101,6 +101,8 @@ export const fileLoader: LoaderFunction = async ({
path: projectPath, path: projectPath,
}) })
// Update both the state and the editor's code. // Update both the state and the editor's code.
// We explicitly do not write to the file here since we are loading from
// the file system and not the editor.
codeManager.updateCodeStateEditor(code) codeManager.updateCodeStateEditor(code)
kclManager.executeCode(true) kclManager.executeCode(true)