Handling Empty Mesh Inputs with GLSL Shaders?

I’m currently using a GLSL shader, where I have a mesh that serves as an input to the shader. My shader works well when the mesh input is valid.

However, I’ve run into an issue when the mesh input is empty, the previous frame is still being displayed.

I understand that shaders don’t have a concept of memory or a state between frames, and they simply operate on whatever data is in the GPU memory. Also, I know that the concept of discarding a buffered visualization is not something that can be handled at the shader level, as shaders don’t control when or how the frame buffer is cleared.

I’ve made a small demo scene , to communicate the effect.

I want to display different shaders using the Item Selector.

Any guidance or pointers in the right direction would be greatly appreciated.
item_select_shader.gh (17.8 KB)

PS: I know in this example this works, but I my real script it is more akin to the first post

item_select_shader_2.gh (17.0 KB)