byte-vortex commited on
Commit
5c0d199
·
verified ·
1 Parent(s): 86ba024

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/interface.py +27 -25
ui/interface.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import html
3
 
4
- import gradio as gr
5
  from game.engine import get_myco_narrative
6
 
7
  def cute_mushroom_garden_html() -> str:
@@ -192,27 +191,30 @@ def cute_mushroom_garden_html() -> str:
192
 
193
 
194
  def render_shroom_tab():
195
- # 1. Assign the block to 'demo' so it can be returned
196
- with gr.Blocks() as demo:
197
- with gr.Tabs():
198
- with gr.Tab("✨ Magic Mushroom Garden"):
199
- # The pure animation
200
- gr.HTML(value=cute_mushroom_garden_html())
201
-
202
- # Subtle attribution
203
- gr.Markdown(
204
- "<sub>*Story generated by Myco AI*</sub>",
205
- elem_id="ai-attribution"
206
- )
207
-
208
- # 2. Define the narrative component ONCE
209
- narrative = gr.Markdown(
210
- value="Myco is searching for a story hidden in the moss...",
211
- elem_id="narrative-card"
212
- )
213
-
214
- # 3. Timer updates the ONE narrative component
215
- gr.Timer(20).tick(fn=get_myco_narrative, outputs=narrative)
216
-
217
- return demo
218
-
 
 
 
 
1
  import gradio as gr
2
  import html
3
 
 
4
  from game.engine import get_myco_narrative
5
 
6
  def cute_mushroom_garden_html() -> str:
 
191
 
192
 
193
  def render_shroom_tab():
194
+ """Renders the Magic Mushroom Garden into the CALLER's current Blocks
195
+ context. Must be called from inside an existing `with gr.Blocks():`
196
+ (e.g. from within a gr.Tab() in build_app()) — do NOT wrap this in its
197
+ own `with gr.Blocks():`, or these components and the narrative Timer
198
+ end up in a separate Blocks graph that never gets launched, so the tab
199
+ renders empty and the Timer never fires.
200
+ """
201
+ with gr.Tabs():
202
+ with gr.Tab("✨ Magic Mushroom Garden"):
203
+ # The pure animation
204
+ gr.HTML(value=cute_mushroom_garden_html())
205
+
206
+ # Subtle attribution
207
+ gr.Markdown(
208
+ "<sub>*Story generated by Myco AI*</sub>",
209
+ elem_id="ai-attribution"
210
+ )
211
+
212
+ # Define the narrative component ONCE
213
+ narrative = gr.Markdown(
214
+ value="Myco is searching for a story hidden in the moss...",
215
+ elem_id="narrative-card"
216
+ )
217
+
218
+ # Timer updates the ONE narrative component
219
+ gr.Timer(20).tick(fn=get_myco_narrative, outputs=narrative)
220
+