dont bust cache on external file change (#6756)

* dont bust cache on external file change

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dont bust cache on external file change

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dont bust cache on external file change

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add to the comment

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-05-08 02:33:32 -07:00
committed by GitHub
parent 0550eef701
commit 89c345649d
2 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,5 @@
import toast from 'react-hot-toast'
import { BSON } from 'bson'
import type { Configuration } from '@rust/kcl-lib/bindings/Configuration'
import type { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes'
import type { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError'
@ -8,7 +7,9 @@ import type { OutputFormat3d } from '@rust/kcl-lib/bindings/ModelingCmd'
import type { Node } from '@rust/kcl-lib/bindings/Node'
import type { Program } from '@rust/kcl-lib/bindings/Program'
import type { Context } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib'
import { BSON } from 'bson'
import type { Models } from '@kittycad/lib/dist/types/src'
import type { EngineCommandManager } from '@src/lang/std/engineConnection'
import { fileSystemManager } from '@src/lang/std/fileSystemManager'
import type { ExecState } from '@src/lang/wasm'
@ -25,7 +26,6 @@ import { err, reportRejection } from '@src/lib/trap'
import type { DeepPartial } from '@src/lib/types'
import type { ModuleType } from '@src/lib/wasm_lib_wrapper'
import { getModule } from '@src/lib/wasm_lib_wrapper'
import type { Models } from '@kittycad/lib/dist/types/src'
export default class RustContext {
private wasmInitFailed: boolean = true
@ -155,6 +155,19 @@ export default class RustContext {
}
// Clear/reset the scene and bust the cache.
// Do not use this function unless you absolutely need to. In most cases,
// we should just fix the cache for whatever bug you are seeing.
// The only time it makes sense to run this is if the engine disconnects and
// reconnects. The rust side has no idea that happened and will think the
// cache is still valid.
// Caching on the rust side accounts for changes to files outside of the
// scope of the current file the user is on. It collects all the dependencies
// and checks if any of them have changed. If they have, it will bust the
// cache and recompile the scene.
// The typescript side should never raw dog clear the scene since that would
// fuck with the cache as well. So if you _really_ want to just clear the scene
// AND NOT re-execute, you can use this for that. But in 99.999999% of cases just
// re-execute.
async clearSceneAndBustCache(
settings: DeepPartial<Configuration>,
path?: string